Просмотр файла sdark.mobi/chest/index.php

Размер файла: 17.82Kb
<?php
require_once '../core/system.php';
echo only_reg();
echo ban();
echo blok();
$reqqqv = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `act` != '1' and `sunduk`='1' ");
$sunduk = mysql_num_rows($reqqqv);
$header = "Сундук (".$sunduk."/".$user['sunduk'].")";
mysql_query("UPDATE `user` set `mesto` = 'Сундук' where `id` = '".$user['id']."'");

require_once '../core/head.php';
$reqv = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."'and `sunduk`!='1' and `act` != '1' ");
$rukzak= mysql_num_rows($reqv);
if(isset($_GET['wear'])){ 
$up = mysql_fetch_array(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".intval($_GET['wear'])."' limit 1"));
if(empty($up['id'])){
header('location: /'); exit;
}
$req = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `act` = '1' and `type` =  '".$up['type']."'");
$avto= mysql_num_rows($req);
if($avto>0){
header('location: ?');
$err = 'Снимите надетую вещь';
}
if(!isset($err)) {
$req = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `act` = '1' and `komplekt`='".$up['komplekt']."'");
$weap = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
$req1 = mysql_query("SELECT * from `komplekt` where `id`='".$up['komplekt']."'");
$bonus = mysql_fetch_array($req1);
if($avto==7 && $weap['komplekt']==$up['komplekt']){
mysql_query("INSERT INTO `bonus` set `usr` = ".$user['id'].", `name` = 'Полный комплект', `time` = '".time()."', `bonus`='+$bonus[bon] к параметрам', `image`='1',`typ`='1'");
mysql_query("UPDATE `user` set `sila` = `sila` + '$bonus[bon]', `max_health` = `max_health` + ('$bonus[bon]'*'10'), `zashit` = `zashit` +  '$bonus[bon]' where `id` = '".$user['id']."'");
}
$kompls = mysql_query("SELECT * from `kompl_us` where `id` = '".intval($_GET['wear'])."' and `id_us`='$user[id]'");
$komplls = mysql_query("SELECT * from `kompl_us` where `id` = '".intval($_GET['wear'])."' and `id_us`='$user[id]' and `fleece`>'0'");
$komp2 = mysql_fetch_array($kompls);
$komp4 = mysql_fetch_array($komplls);
mysql_query("UPDATE `user` set `sila` = `sila` + '".$komp2['sila']."', `max_health` = `max_health` + ('".$komp2['hp']."'*'10'), `zashit` = `zashit` + '".$komp2['prot']."' where `id` = '".$user['id']."'");
$avto=mysql_num_rows($komplls);
if($avto>0){
mysql_query("UPDATE `user` set `sila`=`sila`+$komp4[fleece], `zashit`=`zashit`+$komp4[fleece], `max_health`=`max_health`+('$komp4[fleece]'*'10') where `id` = '".$user['id']."' limit 1");
}
$_SESSION['message'] = 'Вы надели вещь';$act = 1;
mysql_query("UPDATE `kompl_us` set `act` = '".$act."' where `id` = '".abs(intval($_GET['wear']))."'");
header('location: ?'); exit;
}else{
header('Location: ?');
$_SESSION['err'] = $err;
}
}
if(isset($_GET['disassembleok'])){
$up = mysql_fetch_array(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['disassembleok']))."' limit 1"));
if(empty($up['id'])){
header('location: /'); exit;
}
$req = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['disassembleok']))."'");
$avto= mysql_num_rows($req);
if($avto==0){
$err = 'Такой вещи не существует!';
}
if(!isset($err)) {
$u2 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id` = '".$up['id_komp']."' limit 1 "));
if($u2['ur']=='5'){$sapfyr=1*$up['lvl'];$text= "<img src=/images/icon/res/sapfyr.png> $sapfyr"; }
if($u2['ur']=='4'){$izumrud=1*$up['lvl'];$text= "<img src=/images/icon/res/izumrud.png> $izumrud";}
if($u2['ur']=='3'){$topaz=1*$up['lvl'];$text= "<img src=/images/icon/res/topaz.png> $topaz";}
if($u2['ur']=='2'){$rubyn=1*$up['lvl'];$text= "<img src=/images/icon/res/rubyn.png> $rubyn";}
if($u2['ur']=='1'){$almaz=1*$up['lvl'];$text= "<img src=/images/icon/res/almaz.png> $almaz";}
mysql_query("UPDATE `user` set `sapfyr` = `sapfyr` + '$sapfyr', `izumrud` = `izumrud` + '$izumrud', `topaz` = `topaz` + '$topaz', `rubyn` = `rubyn` + '$rubyn', `almaz` = `almaz` + '$almaz' where `nick`='$user[nick]'");
$_SESSION['message'] = 'Вещь разобрана на '.$text.'';
header('Location: ?');
mysql_query("DELETE FROM `kompl_us` WHERE `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['disassembleok']))."'");
}else{
header('Location: ?');
$_SESSION['err'] = $err;
}
}
if(isset($_GET['disassemble'])){
echo "<div class='player menuList'>";
echo "</div><div class='foot center'><table  class='d-grey' width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>
<tr>";
echo '<div class="inpc-ar"><div class="empty2"></div>Вы уверены, что хотите разобрать вещь?<div class="empty2"></div>
<td width="40%"><a class="big-but" href="/chest/?disassembleok='.abs(intval($_GET['disassemble'])).'&yes"><div class="imgwrap"><img src="/images/icon/ok.png"></div>Разобрать</a></td>';
echo '<td width="40%"><a class="big-but" href="/chest/"><div class="imgwrap"><img src="/images/icon/error.png"></div>Отмена</a></td></tbody></table></div></div>';
echo "</div>";
include_once '../core/foot.php';exit;
}
if(isset($_GET['yes'])){
$up = mysql_fetch_array(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['sell']))."' limit 1"));
if(empty($up['id'])){
header('location: /'); exit;
}
$req = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['sell']))."'");
$avto= mysql_num_rows($req);
if($avto==0){header('location: /chest/');
$err = 'Такой вещи не существует!';exit;
}
if(!isset($err)) {
$u2 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id` = '".$up['id_komp']."' limit 1 "));
if($up['fleece']==0){
$cena = ($u2['cena']*0.2)*100;
}else{
if($up['fleece']==50){$cena=10000;}
if($up['fleece']==100){$cena=30000;}
if($up['fleece']==300){$cena=90000;}
if($up['fleece']==600){$cena=200000;}
if($up['fleece']==1200){$cena=500000;}
$cena = $cena*0.9;
}
$go=floor($cena/100);
if($cena<100){$skolko='<img src="/images/icon/silver.png">'.$cena.'';}else{$skolko='<img src="/images/icon/gold.png"/>'.$go.' ';}
mysql_query("UPDATE `user` set `gold` = `gold` + '$cena' where `id`='$user[id]'");
$_SESSION['message'] = 'Вещь продана за '.$skolko.'';
header('Location: /chest/');
mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'Продана вещь', `time` = '".time()."', `kol`='$cena', `kto`='+'");
mysql_query("DELETE FROM `kompl_us` WHERE `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['sell']))."'");
}else{
header('Location: /chest/');
$_SESSION['err'] = $err;
}
}
if(isset($_GET['sell'])){
echo "<div class='player menuList'>";
$kom = mysql_query("SELECT * from `kompl_us` where `id_us` = '$user[id]' and `id`='".abs(intval($_GET['sell']))."' ");
$ko = mysql_fetch_array($kom);
$up = mysql_fetch_array(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['sell']))."' limit 1"));
if(empty($up['id'])){
header('location: /chest/'); exit;
}
echo "</div><div class='foot center'><table  class='d-grey' width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>
<tr>";
$u2 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id` = '".$ko['id_komp']."' limit 1 "));
if($ko['fleece']==0){
$cena = ($u2['cena']*0.2)*100;
}else{
if($ko['fleece']==50){$cena=10000;}
if($ko['fleece']==100){$cena=30000;}
if($ko['fleece']==300){$cena=90000;}
if($ko['fleece']==600){$cena=200000;}
if($ko['fleece']==1200){$cena=500000;}
if($ko['fleece']==2500){$cena=1200000;}
$cena = $cena*0.9;
}
$go=floor($cena/100);
if($cena<100){$skolko='<img src="/images/icon/silver.png">'.$cena.'';}else{$skolko='<img src="/images/icon/gold.png"/>'.$go.' ';}
echo '<div class="inpc-ar"><div class="empty2"></div>Вы уверены, что хотите продать вещь за '.$skolko.' ?<div class="empty2"></div>
<td width="40%"><a class="big-but" href="/chest/?sell='.abs(intval($_GET['sell'])).'&yes"><div class="imgwrap"><img src="/images/icon/ok.png"></div>Продать</a></td>';
echo '<td width="40%"><a class="big-but" href="/chest/"><div class="imgwrap"><img src="/images/icon/error.png"></div>Отмена</a></td></tbody></table></div></div>';
echo "</div>";
include_once '../core/foot.php';exit;
}
if(isset($_GET['backpack'])){
if($rukzak>=$user['rukzak']){
header('location: ?');
$err = 'Рюкзак заполнен!';
}
if(!isset($err)) {

$_SESSION['message'] = 'Вещь помещена в рюкзак';
mysql_query("UPDATE `kompl_us` set `sunduk` = '0' where `id` = '".abs(intval($_GET['backpack']))."'");
header('location: ?'); exit;
}else{
header('Location: ?');
$_SESSION['err'] = $err;
}
}
$up = intval($_GET['up']);
if($up=='10' and $user[sunduk]==5 and $user['gold']>=2000){$cena=2000;
$_SESSION['message'] = 'Теперь в твой сундук поместиться больше вещей!';
header('Location: ?');
mysql_query("UPDATE `user` set `sunduk` = '10', `gold`=`gold` - '2000' where `id` = '".$user['id']."'");
}

$gold = intval($_GET['up'])*100;
$sund = intval($_GET['up']);
if(isset($_GET['up'])){
if($user['sunduk']==5){if($sund==20 or  $sund==40 or $sund==90){echo"";}else{header('Location: ?'); $err='Ошибка';}}
if($user['sunduk']==10){if($sund==20 or $sund==70){echo"";}else{header('Location: ?'); $err='Ошибка';}}
if($user['sunduk']==20){if($sund==50){echo"";}else{header('Location: ?'); $err='Ошибка';}}

if($sund==20 and $user['sunduk']==5){$bbs=10;}
if($sund==40 and $user['sunduk']==5){$bbs=20;}
if($sund==90 and $user['sunduk']==5){$bbs=50;}
if($sund==20 and $user['sunduk']==10){$bbs=20;}
if($sund==70 and $user['sunduk']==10){$bbs=50;}
if($sund==50 and $user['sunduk']==20){$bbs=50;}

if($user['sunduk']>=$sund){header('Location: ?'); $err='Ошибка';}
if($user['gold']<$gold){header('Location: ?'); $err = 'Недостаточно золота';}
if(!isset($err)){
$_SESSION['message'] = 'Сундук улучшен до '.$bbs.' вещей';
header('Location: ?');
$ggold=$user['gold']-$gold;
$t=time();
$rest = mysql_result(mysql_query("SELECT COUNT(*) FROM `logi` WHERE `user_id` = '".$user['id']."' and `text` = 'Сундук'"),0);
if($rest==0){mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'Сундук', `time` = '".$t."', `kol`='$gold', `kto`='-'");}else{
mysql_query("UPDATE `logi` set  `time` = '".time()."', `kol`=`kol`+'".$gold."', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'Сундук'");}

mysql_query("UPDATE `user` set `gold` = '$ggold', `sunduk` ='$bbs' where `id` = '".$user['id']."'");
}else{$_SESSION['err'] = $err;}}

$gold = intval($_GET['buy'])*100;
$sundu = intval($_GET['buy']);
if(isset($_GET['buy'])){
if($sundu==10 or  $sundu==30 or $sundu==50  or $sundu==100){echo"";}else{header('Location: ?'); $err='Ошибка';}
if($sundu==10){$bbsu=5;}
if($sundu==30){$bbsu=10;}
if($sundu==50){$bbsu=20;}
if($sundu==100){$bbsu=50;}
if($user['sunduk']>$sundu){header('Location: ?'); $err='Ошибка';}
if($user['gold']<$gold){header('Location: ?'); $err = 'Недостаточно золота';}
if(!isset($err)){
$_SESSION['message'] = 'Сундук успешно куплен';
header('Location: ?');
$ggold=$user['gold']-$gold;
$t=time();
$rest = mysql_result(mysql_query("SELECT COUNT(*) FROM `logi` WHERE `user_id` = '".$user['id']."' and `text` = 'Сундук'"),0);
if($rest==0){mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'Сундук', `time` = '".$t."', `kol`='$gold', `kto`='-'");}else{
mysql_query("UPDATE `logi` set  `time` = '".time()."', `kol`=`kol`+'".$gold."', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'Сундук'");}
mysql_query("UPDATE `user` set `gold` = '$ggold', `sunduk` ='$bbsu' where `id` = '".$user['id']."'");
}else{$_SESSION['err'] = $err;}}

if($user['sunduk']=='0'){
echo"<div class='but-list'><div class='foot'><div class='inpc-ar center'><div class='empty'></div>У вас нет сундука. Приобрести сундук?<div class='empty'></div></div></div>
<a href='/chest/?buy=10'><img src='/images/icon/chest.png' > На 5 вещей за <img src=/images/icon/gold.png>10</a>
<a href='/chest/?buy=30'><img src='/images/icon/chest.png' > На 10 вещей за <img src=/images/icon/gold.png>30</a>
<a href='/chest/?buy=50'><img src='/images/icon/chest.png' > На 20 вещей за <img src=/images/icon/gold.png>50</a>
<a href='/chest/?buy=100'><img src='/images/icon/chest.png' > На 50 вещей за <img src=/images/icon/gold.png>100</a> 
</div><div class='line'></div>";
}

 $k_post = mysql_result(mysql_query("SELECT COUNT(id)  FROM `kompl_us` WHERE `id_us`=".$user['id']." and `act` != '1' and `sunduk`='1'"),0);
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
$kompls = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `act` != '1' and `sunduk`='1' order by `id` DESC LIMIT ".$start.", 10");

while($komp2 = mysql_fetch_array($kompls)){
$komp = mysql_fetch_array(mysql_query("SELECT * FROM `kompl` where `id` = '".$komp2['id_komp']."' limit 1"));
$stat = mysql_fetch_array(mysql_query("SELECT `sila`,`hp`,`prot`  FROM `kompl_us` where `id_us` = '".$user[id]."' and `id` = '".$komp2['id']."'"));
$s=$stat['sila']+$stat['hp']+$stat['prot'];
$stat2 = mysql_fetch_array(mysql_query("SELECT `sila`,`hp`,`prot`  FROM `kompl_us` where `id_us` = '".$user['id']."'  and `type` = '".$komp2['type']."' and `act` = '1' "));
$v=$stat2['sila']+$stat2['hp']+$stat2['prot'];
$st=$s-$v;
echo'<div class="foot"><table width="100%">
<tbody><tr><td width="40" height="40">
    <span><img style="border:1.4px solid #131313;border-radius:3px" width="40" height="40" src="'.$komp['url'].'">
	</span><span> <div class="level">'.$komp2['lvl'].'</div></span>
  </td><td>';
    if($komp2['fleece']==0){$fleece="пусто";}
if($komp2['fleece']>0){$fleece="+$komp2[fleece]";}
if($komp2['fleece']==0){$fleece_img='A4A4A4';}
if($komp2['fleece']==50){$fleece_img='F5D188';}
if($komp2['fleece']==100){$fleece_img='67EE70';}
if($komp2['fleece']==300){$fleece_img='4385F0';}
if($komp2['fleece']==600){$fleece_img='9A52E8';}
if($komp2['fleece']==1200){$fleece_img='FF3042';}
if($komp2['fleece']==2500){$fleece_img='D1D439';}
if($komp['ur']==5){$j="<img src='/images/icon/crys/$komp[ur].png'>";$k="Простая";$f="<font color='F5D188'>";}
if($komp['ur']==4){$j="<img src='/images/icon/crys/$komp[ur].png'>";$k="Обычная";$f="<font color='67EE70'>";}
if($komp['ur']==3){$j="<img src='/images/icon/crys/$komp[ur].png'>";$k="Редкая";$f="<font color='4385F0'>";}
if($komp['ur']==2){$j="<img src='/images/icon/crys/$komp[ur].png'>";$k="Эпическая";$f="<font color='9A52E8'>";}
if($komp['ur']==1){$j="<img src='/images/icon/crys/$komp[ur].png'>";$k="Легендарная";$f="<font color='FF3042'>";}
echo' </td><td >'.$komp['name'].'<span class=float-right><div class="empty"></div>'.$j.''.$f.''.$k.'</font></br>Тип: <font color="E2E2E2">'.$komp['type'].'</font></br> Руна: <font color="'.$fleece_img.'">'.$fleece.'</font></span> ';
 if($st>0){echo" <font color='71cc71'> (+$st)</font>";}
 if($st<0){echo" <font color='FF6633'> ($st)</font>";}echo'
<font color="CDCFCF">
 <div class="empty"></div><img src="/images/icon/stat/prot.png" width="16" height="16"> '.$komp2['prot'].' <img src="/images/icon/stat/hp.png" width="16" height="16"> '.$komp2['hp'].' <img src="/images/icon/stat/sila.png" width="16" height="16"> '.$komp2['sila'].'<div class="empty"></div></font>';
echo' <a class="btn2" href="/chest/?wear='.$komp2['id'].'">
         <span class="but">
        Надеть
      </span>  </a> 
	  ';
	  if($user['sunduk']>0){echo'
	  <a class="btn2" href="/chest/?backpack='.$komp2['id'].'">
         <span class="but">
        В рюкзак
      </span>  </a>  ';}echo'
	  
	  <a class="btn2" href="/chest/?sell='.$komp2['id'].'">
         <span class="but">
        Продать
      </span>  </a>
	  
	  <a class="btn2" href="/chest/?disassemble='.$komp2['id'].'">
         <span class="but">
        Разобрать
      </span>  </a>
	  
	  </table></font></div>
<hr>';

}
if($sunduk==0 and $user['sunduk']>0){echo "<div class='foot'>Нет вещей</div><div class='line'></div>";}
if($user['sunduk']>0 and $user['sunduk']<50){echo"<div class='but-list'><div class='foot'><div class='center inpc-ar'><div class='empty'></div>Увеличить место в сундуке?<div class='empty'></div></div>
</div><hr>";
if($user['sunduk']==5){echo"
<a href='/chest/?up=20'>До 10 вещей за <img src=/images/icon/gold.png>20</a>
<a href='/chest/?up=40'>До 20 вещей за <img src=/images/icon/gold.png>40</a>
<a href='/chest/?up=90'>До 50 вещей за <img src=/images/icon/gold.png>90</a> 
 </div><div class='line'></div>";}
 if($user['sunduk']==10){echo"
<a href='/chest/?up=20'>До 20 вещей за <img src=/images/icon/gold.png>20</a>
<a href='/chest/?up=70'>До 50 вещей за <img src=/images/icon/gold.png>70</a>
 </div><div class='line'></div>";}
 if($user['sunduk']==20){echo"
<a href='/chest/?up=50'>До 50 вещей за <img src=/images/icon/gold.png>50</a>
 </div><div class='line'></div>";}
 }
if ($k_page>1){

str('?',$k_page,$page);
echo "<div class='line'></div>";

}
$reqqv = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `act` = '1' ");
$eq= mysql_num_rows($reqqv);
echo"
<div class='foot'>
<table  width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>
<tr>
<td width='49%'>
<a class='big-but' href='/backpack/'>
<div class='imgwrap'>
<img src='/images/icon/backpack_color.png'>
</div> Рюкзак (".$rukzak."/".$user['rukzak'].")
</a>
</td>
<td width='49%'>
<a class='big-but' href='/user/equipment?id=".$user['id']."'>
<div class='imgwrap'>
<img src='/images/icon/equip.png'></div> Экипировка (".$eq."/8) 
</a> 
</td>
</tbody>
</table>
</div>
</div>
</body>
</html>
</div>";
require_once '../core/foot.php';
?>