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

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

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 `id` 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['chest'])){
if($sunduk>=$user['sunduk']){
header('location: ?');
$err = 'Сундук заполнен!';
}
if(!isset($err)) {

$_SESSION['message'] = 'Вещь помещена в сундук';
mysql_query("UPDATE `kompl_us` set `sunduk` = '1' where `id` = '".abs(intval($_GET['chest']))."'");
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){header('location: /backpack/'); 
$err = 'Такой вещи не существует!';exit;
}
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: /backpack/');
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>";
$up = mysql_fetch_array(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['disassemble']))."' limit 1"));
$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";}
echo '<div class="inpc-ar"><div class="empty2"></div>Вы уверены, что хотите разобрать вещь на '.$text.'?<div class="empty2"></div>
<td width="40%"><a class="big-but" href="/backpack/?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="/backpack/"><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;
}
$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;}
if($up['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.' ';}
mysql_query("UPDATE `user` set `gold` = `gold` + '$cena' where `id`='$user[id]'");
$_SESSION['message'] = 'Вещь продана за '.$skolko.'';
header('Location: ?');
$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` = '".time()."', `kol`='$cena', `kto`='+'");}else{
mysql_query("UPDATE `logi` set `time` = '".$tm."', `kol`=`kol`+'".$cena."', `kto`='+' WHERE `user_id` = '".$user['id']."' and `text` = 'Продана вещь'");}

mysql_query("DELETE FROM `kompl_us` WHERE `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['sell']))."'");

}
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: /backpack/'); 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 cena 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="/backpack/?sell='.abs(intval($_GET['sell'])).'&yes"><div class="imgwrap"><img src="/images/icon/ok.png"></div>Продать</a></td>
<td width="40%"><a class="big-but" href="/backpack/"><div class="imgwrap"><img src="/images/icon/error.png"></div>Отмена</a>
</td>
</tbody>
</table>
</div>
</div>
</div>';
include_once '../core/foot.php';
exit;
}

require_once __DIR__ . '/box.php';
if (haveChests($user['id']) > 0 )
{
	if (isset($_GET['open']))
	{
		$id = (int) abs($_GET['open']);
		if (canOpenThis($id,$user['id']))
		{
			$data = openThis($id,$user['id']);
			$_SESSION['message'] = "Найдено: ".$data['pc'].$data['reward'];
			header(
				sprintf(
					"Location:%s%s",
					'?',uniqid()
					)
				);
			exit;
		} else {
			header(
				sprintf(
					"Location:%s%s",
					'?',uniqid()
					)
				);
			exit;
		}
	}


	$query = mysql_query(
			sprintf(
				"SELECT * FROM `chests_user`  WHERE `user_id`=%d",$user['id']
			)
		);
?>
<table class="foot" width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-top: 5px;">
<tbody>
<tr>

<?
$i=0;
	while ($row = mysql_fetch_object($query))
	{
		$i++; 
		$chest = mysql_fetch_assoc(
				mysql_query(
					"SELECT * FROM `chests` WHERE `id`='".(int) abs($row->chest_id)."'"
				)
			);	
			?>
		
<td width="33%" class="head center" style="border-right: 1px solid #1D1C1A; border-bottom: 1px solid #1D1C1A;">
<a class="big-but-light" href="?open=<?php echo $row->id;?>"><font color="CDCDCD" style="font-size: 10px"><?php echo $chest['name'];?></font><div class="empty2"></div>
<div class="imgwrap"><img src="/images/chests/<?php echo $chest['id'];?>.png" width="50px" height="50px"></div>
<div class="empty2"></div>
<span class="inpc-ar">Открыть</span></a>
</td> 
	<?php	
if(
	 $i % 3 == 0 
) 
	{ echo'</tr>';}	
	

	}

echo'
</tbody>
</table><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 id,type,id_komp,lvl,fleece,prot,hp,sila from `kompl_us` where `id_us` = '".$user['id']."' and `act` = '' and `sunduk`='' order by `id` DESC LIMIT ".$start.", 10");
while($komp2 = mysql_fetch_array($kompls)){
$komp = mysql_fetch_array(mysql_query("SELECT type,url,ur,name 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="/backpack/?wear='.$komp2['id'].'">
         <span class="but">
        Надеть
      </span>  </a> 
	  ';
if($user['sunduk']>0){
	echo'
	  <a class="btn2" href="/backpack/?chest='.$komp2['id'].'">
         <span class="but">
        В сундук
      </span>  </a>  ';}
echo'<a class="btn2" href="/backpack/?sell='.$komp2['id'].'">
         <span class="but">
        Продать
      </span>  </a>
	  <a class="btn2" href="/backpack/?disassemble='.$komp2['id'].'">
         <span class="but">
        Разобрать
      </span>  </a>
	  
	  </table></font></div>
<hr>';
}

if($rukzak==0){echo "<div class='foot'>Нет вещей</div><div class='line'></div>";}

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

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='/chest/'><div class='imgwrap'><img src='/images/icon/chest.png'></div> Сундук (".$sunduk."/".$user['sunduk'].")</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> Экипировка </a> </td></tbody></table></div></div>";

echo'</body>
</html>';
echo "</div>";
require_once '../core/foot.php';
?>