<?
if(isset($_GET['start']))
{
if($_GET['start']==10 AND $ku['level']>=39){$is=10;
if($ku['level']>54)$money = 100000000; else $money=10000000;
}
else if($_GET['start']==1){$is=1;
if($ku['level']>54)$money = 10000000; else $money=1000000;}
else {
$_SESSION['msg_err']='Произошла ошибка';
header("Location:/lottery");
exit;
}
if($ku['money']>=$money)
{

$opm=0;
$opr=0;
$orat=0;
$i=1;
WHILE($i<=$is){
$rm=rand(0,100); //монеты
$rr=rand(0,100); //рубины
if($ku['level']>=35 && $ku['level']<39)
{
$rrat=rand(300,500);
$rating=intval("".$rrat."000");
$rat=$rating;
$rat_drakon_act=0;
$arena_rat=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*200);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/100));
$rat=$rat_drakon_act+$arena_rat+$rat;

if($rm==40 || $rm==70 || $rm==100)
{
$pm="".rand(1,10)."00000";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,20);
$pre=1;
}
}
//опыт монеты рубины
if($ku['level']>=39 && $ku['level']<42)
{
$rrat=rand(300,700);
$rating=intval("".$rrat."000");
$rat=$rating;
$rat_drakon_act=0;
$arena_rat=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*200);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/100));
$rat=$rat_drakon_act+$arena_rat+$rat;

if($rm==40 || $rm==70 || $rm==100)
{
$pm="".rand(1,3)."000000";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,10);
$pre=1;
}
}
//опыт монеты рубины
if($ku['level']>=42 AND $ku['level']<50)
{
$rrat=rand(300,9000);
$rating=intval("".$rrat."000");
$rat=$rating;
$rat_drakon_act=0;
$arena_rat=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*200);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/100));
$rat=$rat_drakon_act+$arena_rat+$rat;

if($rm==40 || $rm==70 || $rm==100)
{
$pm="".rand(1,5)."000000";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,20);
$pre=1;
}
}
elseif($ku['level']>=50 AND $ku['level']<55)
{
if($ku['level']>=50 AND $ku['level']<55)$rrat=rand(9,30);
$rating=intval("".$rrat."000000");
$rat=$rating;
$rat_drakon_act=0;
$arena_rat=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*200);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/100));
$rat=$rat_drakon_act+$arena_rat+$rat;

if($rm==40 || $rm==70 || $rm==100)
{
$pm="".rand(1,5)."000000";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,25);
$pre=1;
}
}
elseif($ku['level']>=55 AND $ku['level']<60)
{
$rrat=rand(50,70);
$rating=intval("".$rrat."0000000");
$rat=$rating;
$rat_drakon_act=0;
$arena_rat=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*200);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/100));
$rat=$rat_drakon_act+$arena_rat+$rat;

if($rm==40 || $rm==70 || $rm==100 || $rr==30 || $rr==50 || $rr==60)
{
$pm="".rand(10,30)."000000";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100 || $rr==20 || $rr==30 || $rr==50 || $rr==60)
{
$pr=rand(10,50);
$pre=1;
}
}
elseif($ku['level']>=60)
{
$rrat=rand(100,140);
$rating=intval("".$rrat."0000000");
$rat=$rating;
$rat_drakon_act=0;
$arena_rat=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*200);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/100));
$rat=$rat_drakon_act+$arena_rat+$rat;

if($rm==40 || $rm==70 || $rm==100 || $rr==30 || $rr==50 || $rr==60)
{
$pm="".rand(10,40)."000000";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100 || $rr==20 || $rr==30 || $rr==50 || $rr==60)
{
$pr=rand(20,50);
$pre=1;
}
}
if(!isset($pm))$pm=0;
if(!isset($pr))$pr=0;
$orat=$rat+$orat;
$opm=$pm+$opm;
$opr=$pr+$opr;
$i++;
$pm=0;
$pr=0;
}//while end
//опыт монеты рубины
//конец //обновление базы
if(isset($dexp) AND !isset($dexp3))$orat=$orat*2; elseif(isset($dexp3))$orat=$orat*3;
update_ku('rating',($ku['rating']+$orat));
$ku['money']=minus_money($money);
update_mc($orat);

if(isset($pme))$ku['money']=plus_money($opm);

if(isset($pre))$ku['rubies']=plus_rubies($opr);

$otime_shmel=0;
$otime_yastreb=0;
$otime_drakon=0;
$otime_scr=0;
$otime_dog=0;
$otime_hidro=0;
$i=1;
WHILE($i<=$is){
$rsh=rand(0,100); //шмель
$rya=rand(0,100); //ястреб
$rd=rand(0,100); //дракон
$rsc=rand(0,100); //пугало
$rsd=rand(0,100); //собака
$rhp=rand(0,100); //гидропоника


if($rsh==10 || $rsh==40 || $rsh==70 || $rsh==100 || ($ku['level']>=55 && ($rsh==20 || $rsh==30 || $rsh==50 || $rsh==60)))
{
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku['time_shmel']>$time?"".($ku['time_shmel']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$rshe=1;
$otime_shmel=$otime_shmel+$timee;
}
if($rya==10 || $rya==40 || $rya==70 || $rya==100 || ($ku['level']>=55 && ($rya==20 || $rya==30 || $rya==50 || $rya==60)))
{
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku['time_yastreb']>$time?"".($ku['time_yastreb']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$ryae=1;
$otime_yastreb=$otime_yastreb+$timee;
}
if($rd==10 || $rd==40 || $rd==70 || $rd==100 || ($ku['level']>=55 && ($rd==20 || $rd==30 || $rd==50 || $rd==60)))
{
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku['time_drakon']>$time?"".($ku['time_drakon']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$rde=1;
$otime_drakon=$otime_drakon+$timee;
}
if($rsc==10 || $rsc==40 || $rsc==70 || $rsc==100 || ($ku['level']>=55 && ($rsh==20 || $rsh==30 || $rsh==50 || $rsh==60)))
{
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = '".($ku['scarecrow_time']>$time?"".($ku['scarecrow_time']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$psce=1;
$otime_scr=$otime_scr+$timee;
}
if($rsd==10 || $rsd==40 || $rsd==70 || $rsd==100 || ($ku['level']>=55 && ($rsd==20 || $rsd==30 || $rsd==50 || $rsd==60)))
{
$timee=3600;
$ps=50;
if($ku['dog_time']>$time)
{
$ps=$ku['dog_type']+$ps;
if($ps>200)$ps=200;
}
mysql_query("UPDATE `kolhoz_user` SET `dog_time` = '".($ku['dog_time']>$time?"".($ku['dog_time']+$timee)."":"".($time+$timee)."")."', `dog_type` = '$ps' WHERE `id` = '$ku[id]'");
$dspe=1;
$otime_dog=$otime_dog+$timee;
}
if($rhp==10 || $rhp==40 || $rhp==70 || $rhp==100 || ($ku['level']>=55 && ($rhp==20 || $rhp==30 || $rhp==50 || $rhp==60)))
{
$timee=3600;
$ps=50;
if($ku['hydropinics_time']>$time)
{
$ps=$ku['hydropinics_type']+$ps;
if($ps>400)$ps=400;
}
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time` = '".($ku['hydropinics_time']>$time?"".($ku['hydropinics_time']+$timee)."":"".($time+$timee)."")."', `hydropinics_type` = '$ps' WHERE `id` = '$ku[id]'");
$phpe=1;
$otime_hidro=$otime_hidro+$timee;
}
$i++;
}//конец второго цикла
echo "<div class='feedback'><img width='16' height='16' src='/images/icons/experience.png' alt='o'> Опыт +<span>$orat</span></div>";
}
else
{
$_SESSION['no_money']=$money-$ku['money'];
header("Location:/lottery");
}
}
echo "<div class='event'><h1>Лотерея ''Спринт''</h1></div>";
echo "<div class='content'><div class='block'>";
echo "<ul><li><img width='16' height='16' src='images/icons/ticket.png' alt=''>
<a href='/lottery/start-1'>Купить билет</a> <span><img width='16' height='16' src='images/icons/money.png' alt='o'> <span class='title'>".($ku['level']>54?"10":"1")." млн.</span></span></li>";
if($ku['level']>=39)echo"<li><img width='16' height='16' src='images/icons/ticket.png' alt=''> <a href='/lottery/start-10'>Купить 10 билетов</a> <span><img width='16' height='16' src='/images/icons/money.png' alt='o'> <span class='title'>".($ku['level']>54?"100":"10")." млн.</span></span></li>";

if(isset($_GET['start']) && $ku['money']>=$money)
{
echo "<li class='title pt'>Ваш выигрыш:</li>";
echo "<li><span><ul>";
echo "<li><span><img width='16' height='16' src='/images/icons/experience.png' alt='o'> <span class='title'>".rating($orat)."</span><span class='minor'> (<span>$orat</span>)</span></span></li>";
if(isset($pme))echo "<li><span><img width='16' height='16' src='/images/icons/money.png' alt='o'> <span class='title'>$opm</span></li>";
if(isset($pre))echo "<li><span><img width='16' height='16' src='/images/icons/ruby.png' alt='o'> <span class='title'>$opr</span></li>";
echo "<li></li></ul></span></li>";
if(isset($psce))echo "<li><span><img width='16' height='16' src='/images/icons/scarecrow.png' alt='o'> Пугало на <span class='title'>".(time_left($otime_scr))."</span></li>";
if(isset($dspe))echo "<li><span><img width='16' height='16' src='/images/icons/dog.png' alt='*'> Собака на <span class='title'>".(time_left($otime_dog))."</span></li>";
if(isset($phpe))echo "<li><span><img width='16' height='16' src='/images/icons/hydropinics.png' alt='o'> Гидропоника на <span class='title'>".(time_left($otime_hidro))."</span></li>";
if(isset($rshe))echo "<li><span><img width='16' height='16' src='/images/icons/heli1n.png' alt='o'> Шмель на <span class='title'>".(time_left($otime_shmel))."</span></li>";
if(isset($ryae))echo "<li><span><img width='16' height='16' src='/images/icons/heli2n.png' alt='o'> Ястреб на <span class='title'>".(time_left($otime_yastreb))."</span></li>";
if(isset($rde))echo "<li><span><img width='16' height='16' src='/images/icons/heli3n.png' alt='o'> Дракон на <span class='title'>".(time_left($otime_drakon))."</span></li>";
}
echo "<li class='pt minor'>Минимальный выигрыш <img width='16' height='16' src='/images/icons/experience.png' alt='o'> 300000 k</li>";
echo "</ul></div>";
include_once 'inc/foot.php';
?>