Просмотр файла sdark.mobi/shop/kompl.php

Размер файла: 12.82Kb
<?php
require_once '../core/system.php';
echo only_reg();
echo ban();
$spis = mysql_fetch_array(mysql_query("SELECT * FROM `komplekt` where `id` = '".abs(intval($_GET['id']))."' limit 1"));
$cpcp = $spis['cena']*0.90;
$header = $spis['name'];
require_once '../core/head.php';

if($spis['id'] > 99 && $user['prava'] < 4){
header('location:/'); 
exit;
}

$kompls = mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' order by `id` asc");
$komp = mysql_fetch_array($kompls);
$stat = explode(';',$komp['stats']);
if(empty($spis['name'])){ 
header('location:/'); exit;
}
if(isset($_GET['yes'])){
$reqv = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `sunduk` != '1' and `act` != '1' ");
$rukzak= mysql_num_rows($reqv);
$infor = mysql_fetch_array(mysql_query("SELECT cena,type,fleece from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `id` = '".abs(intval($_GET['tov']))."' limit 1"));
$infor['cena']=$infor['cena']*100;
//$infor['cena']=floor($infor['cena']*0.75);
if(empty($infor['cena'])){header('location: ?'); 
header('location: /'); 
}elseif($user['gold']<$infor['cena']){header("location: kompl?id=".abs(intval($_GET['id'])).""); 
$_SESSION['err'] = 'Недостаточно золота';
}elseif($rukzak>=$user['rukzak']){header("location: kompl?id=".abs(intval($_GET['id']))."");$_SESSION['err'] = 'Рюкзак заполнен!';}
elseif($user['level']<$spis['lvl']){header("location: kompl?id=".abs(intval($_GET['id'])).""); 
$_SESSION['err'] = 'Ваш уровень не позволяет купить данный предмет';
}else{header("location: kompl?id=".abs(intval($_GET['id'])).""); 
$_SESSION['message'] = 'Предмет успешно куплен';
$time=time();
mysql_query("UPDATE `user` set `gold` = `gold` - '".$infor['cena']."' where `id` = '".$user['id']."' limit 1");
mysql_query("INSERT INTO `kompl_us` set `type` = '".$infor['type']."', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".abs(intval($_GET['tov']))."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$infor[fleece]'");

$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`='".$infor['cena']."', `kto`='-'");}else{
mysql_query("UPDATE `logi` set `time` = '".$tm."', `kol`=`kol`+'".$infor['cena']."', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'Вещь'");}

$av = mysql_num_rows(mysql_query("SELECT * FROM `task` WHERE `usr`='$user[id]' and `status`='2' and `task`='6'"));
if($av>0){mysql_query("UPDATE `task` SET `min` = `min`+'1'  WHERE `usr`='$user[id]' and `status`='2' and `task`='6'");}

}
}

if(isset($_GET['ok'])){
$reqv = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' and `sunduk` != '1' and `act` != '1' ");
$rukzak= mysql_num_rows($reqv);
$cpcpc = $cpcp*100;
if($user['gold'] < $cpcpc){
$_SESSION['err'] = 'Недостаточно золота';
header("location: kompl?id=".abs(intval($_GET['id'])).""); 
exit;
} elseif($rukzak >= $user['rukzak']){
$_SESSION['err'] = 'Рюкзак заполнен!';
header("location: kompl?id=".abs(intval($_GET['id']))."");
exit;
}
elseif($user['level'] < $spis['lvl']){
$_SESSION['err'] = 'Ваш уровень не позволяет купить данный комплект';
header("location: kompl?id=".abs(intval($_GET['id'])).""); 
exit;
} else {
$_SESSION['message'] = 'Комплект успешно куплен';
header("location: kompl?id=".abs(intval($_GET['id'])).""); 
$time=time();
mysql_query("UPDATE `user` set `gold` = `gold` - '".$cpcpc."' where `id` = '".$user['id']."' limit 1");

$equ1 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='голова' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'голова', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ1['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ1[fleece]'");
 $equ2 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='рука 1' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'рука 1', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ2['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ2[fleece]'");
 $equ3 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='рука 2' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'рука 2', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ3['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ3[fleece]'");
 $equ4 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='плечи' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'плечи', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ4['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ4[fleece]'");
 $equ5 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='тело' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'тело', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ5['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ5[fleece]'");
 $equ6 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='ноги' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'ноги', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ6['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ6[fleece]'");
 $equ7 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='кольцо' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'кольцо', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ7['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ7[fleece]'");
 $equ8 = mysql_fetch_array(mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `type`='шея' limit 1"));
mysql_query("INSERT INTO `kompl_us` set `type` = 'шея', `komplekt`=".abs(intval($_GET['id'])).", `id_komp` = '".$equ8['id']."', `id_us` = '".$user['id']."', `sila`='$stat[1]', `prot`='$stat[2]', `hp`='$stat[0]', `fleece`='$equ8[fleece]'");
 
$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`='".$cpcpc."', `kto`='-'");
} else {
mysql_query("UPDATE `logi` set `time` = '".$tm."', `kol`=`kol`+'".$cpcpc."', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'Комплект'");
}
}
}

if(isset($_GET['tov'])){
echo "<div class='player menuList'>";
$kom = mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `id`='".abs(intval($_GET['tov']))."' order by `id` asc");
$ko = mysql_fetch_array($kom);
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>Вы уверены, что хотите купить "'.$ko['name'].'"?
<td width="40%">
<div class="empty2"></div>
<a class="big-but" href="/shop/kompl?id='.abs(intval($_GET['id'])).'&tov='.abs(intval($_GET['tov'])).'&yes"><div class="imgwrap"><img src="/images/icon/ok.png"></div>Купить вещь</a></td>
<td width="40%">
<div class="empty2"></div>
<a class="big-but" href="?id='.abs(intval($_GET['id'])).'"><div class="imgwrap"><img src="/images/icon/error.png"></div>Отмена</a>
</td>
</tbody>
</table>
</div></div></div>
<div class="line"></div>';
}

if(isset($_GET['allequip'])) {
echo "<div class='player menuList'>";
$kom = mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' and `id`='".abs(intval($_GET['tov']))."' order by `id` asc");
$ko = mysql_fetch_array($kom);
echo'</div>
<div class="foot center">
<table  class="d-grey" width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-top: 5px;">
<tbody>
<tr>
<div class="inpc-ar"><div class="empty2"></div>Вы уверены, что хотите купить весь комплект за <img src="/images/icon/gold.png">'.$cpcp.'?
<td width="40%">
<div class="empty2"></div>
<a class="big-but" href="/shop/kompl?id='.abs(intval($_GET['id'])).'&allequip='.$spis['id'].'&ok">
<div class="imgwrap"><img src="/images/icon/ok.png"></div>Купить комплект</a></td>
<td width="40%">
<div class="empty2"></div>
<a class="big-but" href="?id='.abs(intval($_GET['id'])).'">
<div class="imgwrap">
<img src="/images/icon/error.png"></div>Отмена</a>
</td>
</tbody>
</table>
</div></div></div>
<div class="line"></div>';

}

$kompls = mysql_query("SELECT * from `kompl` where `id_komp` = '".abs(intval($_GET['id']))."' order by `id` asc");
while($komp = mysql_fetch_array($kompls)){
$stat = explode(';',$komp['stats']);
$s=$stat[0]+$stat[1]+$stat[2];
$stat2 = mysql_fetch_array(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `type` = '$komp[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">'.$komp['lvl'].'</div></span>
  </td><td>';
if($komp['fleece']==0){$fleece="пусто";}
if($komp['fleece']>0){$fleece="+$komp[fleece]";}
if($komp['fleece']==0){$fleece_img='A4A4A4';}
if($komp['fleece']==50){$fleece_img='F5D188';}
if($komp['fleece']==100){$fleece_img='67EE70';}
if($komp['fleece']==300){$fleece_img='4385F0';}
if($komp['fleece']==600){$fleece_img='9A52E8';}
if($komp['fleece']==1200){$fleece_img='FF3042';}
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>";}
 //$komp['cena']=floor($komp['cena']*0.75); 
 echo'
<font color="A6A39D">
 <div class="empty"></div><img src="/images/icon/stat/hp.png" width="16" height="16">'.$stat[1].' <img src="/images/icon/stat/sila.png" width="16" height="16">'.$stat[2].' <img src="/images/icon/stat/prot.png" width="16" height="16">'.$stat[0].' <div class="empty"></div></font>
 <a class="btn2" href="/shop/kompl?id='.abs(intval($_GET['id'])).'&tov='.$komp['id'].'">
      <span class="but">
       '.(($komp['cena']>$user['gold'] || $user['level']<$spis['lvl'])?'':null).'Купить  за  
        <img src="/images/icon/gold.png" alt="gold">'.$komp['cena'].' 
     </table></font></div>
<hr>';
}
//(<font color="F2F745">-20%</font>)


$spis = mysql_fetch_array(mysql_query("SELECT * FROM `komplekt` where `id` = '".abs(intval($_GET['id']))."' limit 1"));

echo"<div class='foot'>
<a class='inpc-ar center' href='?id=".$spis['id']."&allequip=".$spis['id']."''>Купить весь комплект за <img src='/images/icon/gold.png'><font color='CDCDCD'>".$cpcp."</font> (<font color='F2F745'>-10%</font>)<br></a>
</div><div class='line'></div>
<div class='main'> <div class='empty2'></div><center>Полный комплект дает бонус +$spis[bon] к <img src='/images/icon/stat/hp.png' width='16 height='16'><img src='/images/icon/stat/sila.png' width='16 height='16'><img src='/images/icon/stat/prot.png' width='16 height='16'><div class='empty2'></div>";
 
echo'</center></font></font></div>';
include_once '../core/foot.php';
?>