<?
if(isset($_GET['start']))
{
$almaz=10;
if($ku['almaz']>=$almaz)
{

$rm=rand(0,50);
$rr=rand(0,50);
$rsh=rand(0,50);
$rya=rand(0,50);
$rd=rand(0,100);
$rsc=rand(0,50);
$rhp=rand(0,100);

if($ku['level']>=11 && $ku['level']<39)
{
$rrat=rand(30,50);
$rating=intval("".$rrat."0");
$rat=$rating;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
$rat=$rat_drakon_act+$rat_school_act+$rat_lib_act+$rat;
$rating=$rat;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
update_mc($rat);
if($rm==10 || $rm==40 || $rm==70 || $rm==100)
{
$pm="".rand(1,10)."0";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,20);
$pre=1;
}
}

if($ku['level']>=1 && $ku['level']<11)
{
$rrat=rand(15,40);
$rating=intval("".$rrat."0");
$rat=$rating;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
$rat=$rat_drakon_act+$rat_school_act+$rat_lib_act+$rat;
$rating=$rat;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
update_mc($rat);
if($rm==10 || $rm==40 || $rm==70 || $rm==100)
{
$pm="".rand(1,10)."0";
$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']<50)
{
$rrat=rand(30,70);
$rating=intval("".$rrat."0");
$rat=$rating;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
$rat=$rat_drakon_act+$rat_school_act+$rat_lib_act+$rat;

$rating=$rat;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
update_mc($rat);
if($rm==10 || $rm==17 || $rm==42 || $rm==56 || $rm==70 || $rm==99)
{
$pm="".rand(1,10)."0";
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,50);
$pre=1;
}
}
elseif($ku['level']>=50)
{
$rrat=rand(30,10);
$rating=intval("".$rrat."0");
$rat=$rating;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
$rat=$rat_drakon_act+$rat_school_act+$rat_lib_act+$rat;
$rating=$rat;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
update_mc($rat);
if($rm==10 || $rm==18 || $rm==40 || $rm==55 || $rm==70 || $rm==100)
{
$pm=rand(1,100);
$pm=intval($pm);
$pme=1;
}
if($rr==10 || $rr==20 || $rr==21  || $rr==40 || $rr==70 || $rr==100)
{
$pr=rand(1,1000);
$pre=1;
}
}
if(isset($pme))mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `money` = '".($ku['money']+$pm)."' WHERE `id` = '$ku[id]'");

if(isset($pre))mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `rubies` = '".($ku['rubies']+$pr)."' WHERE `id` = '$ku[id]'");

if($rsh==10 || $rsh==40 || $rsh==70 || $rsh==100)
{
$timee=3600;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `time_shmel` = '".($ku['time_shmel']>$time?"".($ku['time_shmel']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$rshe=1;
}
if($rya==10 || $rya==40 || $rya==70 || $rya==100)
{
$timee=3600;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `time_yastreb` = '".($ku['time_yastreb']>$time?"".($ku['time_yastreb']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$ryae=1;
}
if($rd==10 || $rd==40 || $rd==70 || $rd==100)
{
$timee=3600;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `time_drakon` = '".($ku['time_drakon']>$time?"".($ku['time_drakon']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$rde=1;
}
if($rsc==10 || $rsc==40 || $rsc==70 || $rsc==100)
{
$timee=3600;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `scarecrow_time` = '".($ku['scarecrow_time']>$time?"".($ku['scarecrow_time']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$rsce=1;
}
if($rhp==10 || $rhp==40 || $rhp==70 || $rhp==100)
{
$timee=3600;
$ps=300;
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `hydropinics_time` = '".($ku['hydropinics_time']>$time?"".($ku['hydropinics_time']+$timee)."":"".($time+$timee)."")."', `hydropinics_type` = '$ps' WHERE `id` = '$ku[id]'");
$rhpe=1;
}
echo "<div class='feedback'><img width='16' height='16' src='images/icons/experience.png' alt='o'> Опыт +<span>$rat</span></div>";
}
else
{
$_SESSION['no_diam']=$almaz-$ku['almaz'];
header("Location:?lotteryk");
}
}
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='o'>
<a href='?lotteryk&start=1'>Купить билет</a> <span><img width='16' height='16' src='images/icons/almaz.png' alt='o'> <span class='title'>$almaz</span></span>
</li>";
if(isset($_GET['start']) && $ku['almaz']>=$almaz)
{
mysql_query("UPDATE `$db_base`.`kolhoz_user` SET `almaz` = '".($ku['almaz']-$almaz)."' WHERE `id` = '$ku[id]'");

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($rating)."</span><span class='minor'> (<span>$rating</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'>$pm</span></li>";
if(isset($pre))echo "<li><span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>$pr</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'>1 час.</span></li>";
if(isset($phpe))echo "<li><span><img width='16' height='16' src='images/icons/hidropinics.png' alt='o'> Гидропоника на <span class='title'>1 час.</span></li>";
if(isset($rshe))echo "<li><span><img width='16' height='16' src='images/icons/heli1n.png' alt='o'> Шмель на <span class='title'>1 час.</span></li>";
if(isset($ryae))echo "<li><span><img width='16' height='16' src='images/icons/heli2n.png' alt='o'> Ястреб на <span class='title'>1 час.</span></li>";
if(isset($rde))echo "<li><span><img width='16' height='16' src='images/icons/heli3n.png' alt='o'> Дракон на <span class='title'>1 час.</span></li>";
}
echo "<font color='#ffffff'>Данный раздел поможет вам поднять уровень за счет <img width='16' height='16' src='images/icons/almaz.png' alt='o'> <b>Алмазов</b>!</br>Которые можно поймать во время общения или просто прогулки по игре.</font>";
echo "</ul></div>";

include_once 'inc/foot.php';
exit;

?>