<?php
require_once 'core/system.php';



date_default_timezone_set('Europe/Moscow');

reg();

head('Ярмарка');



?><style>.rare-baloon {    right: 32px;    padding: 7px;}


.rare-recommend-header {    background: url('/img/fair/back_lavka_480x120.jpg') 50% 50% no-repeat #000;}.rare-wrap {    position: relative;    height: 120px;    width: 320px;    margin: 0 auto 24px auto;}.rare-baloon {    position: absolute;    top: 5px;    right: 5px;    width: 45%;    padding: 10px;    background: #bfb8a7;    border-radius: 5px;    font-size: 12px;    color: #271f0a;}.rare-baloon:before {    content: '';    display: block;    position: absolute;    top: 30px;    left: -20px;    border-width: 15px 20px 0 0;    border-style: solid;    border-color: transparent #bfb8a7;    width: 0;}



</style><?












$dop=$dbc->query("SELECT * FROM `dop` where `user`= '".$user['id']."' ")->fetch_assoc(); 



$bui=$dbc->query("SELECT * FROM `aluko` where `id`= 1 ")->fetch_assoc(); 


 $gold  = 30+$dop['fair'];
 
 $super =  mt_rand(1,25);
 
 

if(isset($_GET['game'])){ 



if($user['level']<1){   header('location:fair.php'); exit;} 




if($user['gold']<$gold){  $_SESSION['message']='Недостаточно Золота'; header('location:fair.php'); exit;} 







$rand  =  mt_rand(1,6);






if($rand==1){


$dbc->query("UPDATE `users` SET `gold`=`gold`+150 WHERE `id`='".$user['id']."'");
 

$_SESSION['message']='Вы выиграли <img src="img/money/money.png">150';
$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' Выиграл <img src="/img/money/money.png">150';


$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }

if($rand==2){


$dbc->query("UPDATE `users` SET `serebro`=`serebro`+100000 WHERE `id`='".$user['id']."'");
 

$_SESSION['message']='Вы выиграли <img src="img/stat/sera.png">100000';
$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' Выиграл <img src="/img/stat/sera.png">100000';


$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }




if($rand==3){


$dbc->query("UPDATE `users` SET `rub`=`rub`+1000 WHERE `id`='".$user['id']."'");
 

$_SESSION['message']='Вы выиграли <img src="img/money/rubin.png">1000';
$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' Выиграл <img src="/img/money/rubin.png">1000';


$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }


if($rand==4){


$dbc->query("UPDATE `dop` SET `boi`=`boi`+5 WHERE `user`='".$user['id']."'");

 

$_SESSION['message']='Вы выиграли <img src=/img/ohot/sv.png>5';



$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' Выиграл <img src=img/ohot/sv.png>5';





$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }





if($rand==5){


$dbc->query("UPDATE `users` SET `leg`=`leg`+50 WHERE `id`='".$user['id']."'");


 

$_SESSION['message']='Вы выиграли <img src=img/new/leg.png>50';



$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' Выиграл <img src=img/new/leg.png>50';





$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }





if($rand==6){


$dbc->query("UPDATE `users` SET `rub`=`rub`+500 WHERE `id`='".$user['id']."'");

 

$_SESSION['message']='Вы выиграли <img src=img/money/rubin.png>500';



$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' Выиграл <img src=img/money/rubin.png>500';






$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }










$dbc->query("UPDATE `users` SET `gold`=`gold`-'".$gold."' WHERE `id`='".$user['id']."'");


$dbc->query("UPDATE `dop` SET `fair`=`fair`+10 WHERE `user`='".$user['id']."'");




$dbc->query("UPDATE `aluko` SET `fair`=`fair`+3 WHERE `id`=1");




$san  = $bui['fair'];

$chh  = 7;

 $super =  mt_rand(1,25);

$_SESSION['trys']="$super";

if($super == 5 and $bui['fair']>300 ){









$dbc->query("UPDATE `users` SET `gold`=`gold`+'".$bui['fair']."' WHERE `id`='".$user['id']."'");
 
$dbc->query("UPDATE `aluko` SET `fair`=0 WHERE `id`=1");

$_SESSION['message']='<span class=iLegendary>Вы Выиграли Джепкот<img src="img/money/money.png">'.$san.'</span>';
$sop  ='<img src="/img/class/'.$user['storona'].'/'.$user['pers'].'/pers.png">'.$user['login'].' <span class=iLegendary>Выиграл Джекпот <img src="/img/money/money.png">'.$san.'</span>';


$sent = ("INSERT INTO `new_year` (text,user) values('".$sop."','".$user['id']."')"); 





$dbc->query($sent);  }





header('location:fair.php');exit;













}









?><div class="rare-recommend">

<div class="rare-recommend-header">
<div class="rare-wrap">
<div class="rare-character"></div>
<div class="rare-baloon"> Здравствуй <?=$user['login']?>, когда-нибудь я стану богаче всех на этих землях. но а пока можешь испытать свою удачу в моей лотереи</div>



</div>
</div><?


?><center><a class="btn" href="fair.php?game">Играть за <img src="img/money/money.png"><?=$gold?></a></center><?






?><center>Последние Призы:</ceneter><?


$year = $dbc->query("SELECT * FROM `new_year` ORDER BY `id` DESC LIMIT 10"); 

while($new = $year->fetch_assoc()){  




?><center>
<div class="b-panel-new dblue-panel bordered mt2"><div class="panel-inner-2"><small>




<?=$new['text']?>


</small>
</div></div></center><? }


?><div class="b-panel-new dblue-panel bordered mt2">

<div class="panel-inner-2"><div class="font-small text-italic c-verygray">


Банк:<img src="img/money/money.png"><?=$bui['fair']?></div></div></div><?

if($user['id']==1){ ?><? }




foot();


