<?
if($ku['level']<35)
{
echo "<div class='content'>";
echo "<div class='block'>";
echo'<img src="images/smiles/owibochka.gif" alt="*"></img> Лоторея доступена с 35-го ур!';
echo "</div></div>";
include_once 'inc/foot.php';
exit;
}
if(isset($_GET['start']))
{
$money=10000000;

if($ku['money']>=$money)
{

$rm=rand(0,550);
$rm1=rand(0,250);
$rm2=rand(0,150);
$rrc=rand(0,500);
$rg=rand(0,500);

$rrc1=rand(0,250);
$rrc2=rand(0,20);
$pet=rand(0,100);
$plant=rand(0,120);
$plant2=rand(0,100);
$pet1=rand(0,100);
$rr=rand(0,2320);
$rr1=rand(0,1160);
$rr2=rand(0,1000);
$rr3=rand(0,1000);
$rr4=rand(0,120);
$rr5=rand(0,100);
$rr6=rand(0,30);

$rsh=rand(0,150);
$rya=rand(0,130);
$rd=rand(0,120);
$rsc=rand(0,140);
$rsc1=rand(0,140);
$rsc2=rand(0,140);

$rhp=rand(0,110);
$rc=rand(0,110);
$rk=rand(0,3010);
$rk1=rand(0,2010);
$rk2=rand(0,1010);
$rk3=rand(0,150);
$rose=rand(0,110);
$rose12=rand(0,110);
$rose1=rand(0,110);

if($ku['level']>=34 && $ku['level']<150000)
{
$rrat=rand(3000,3000);
$rating=intval("".$rrat."000");
$rat=$rating;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_lib_act=0;
$rat_acva_act=0;
$rat_opyt1_act=0;
if(isset($opyt1_act))$rat_opyt1_act=(($rat/100)*$ku['opyt1']);

if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($acva_act))$rat_acva_act=(($rat/100)*500);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
$rat=$rat_drakon_act+$rat_opyt1_act+$rat_school_act+$rat_lib_act+$rat_acva_act+$rat;
$rating=$rat;
if(isset($dexp5))$rat=$rat*5;
if(isset($dexp))$rat=$rat*2;

}
$ku['money']=minus_money($money);
if(isset($rat))$ku['rating']=plus_rating($rat);

if($rsh==10 || $rsh==40 || $rsh==70 || $rsh==100)
{
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku['time_shmel']>$time?"".($ku['time_shmel']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `time_shmel_lottery` = '".($ku['time_shmel_lottery']>$time?"".($ku['time_shmel_lottery']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");

$rshe=1;
}
if($rose==100 || $rose==200 || $rose==300 || $rose==500)
{
mysql_query("INSERT INTO `kolhoz_warehouse` SET `id_user` = '$ku[id]', `id_plant` = '55', `count` = '1000000',`arena` = '0',`fish` = '0'");

$rosek=1;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"),0)<98)
if($pet==500 || $pet==1000 || $pet==2000 || $pet==4000)
{
$random=rand(0,57);
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$random'"));
mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '$random', `time` = '0',`time_money` = '0',`level` = '1',`time_money2` = '0',`time_rf` = '0',`last_rf` = '1'");
$pets=1;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"),0)<98)
if($pet1==400 || $pet1==800 || $pet1==1600 || $pet1==3200)
{
mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '0', `time` = '0',`time_money` = '0',`level` = '1',`time_money2` = '0',`time_rf` = '0',`last_rf` = '1'");
$peta=1;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0)<98)
if($plant==400 || $plant==800 || $plant==1600 || $plant==3200)
{
mysql_query("INSERT INTO `kolhoz_ground` SET `id_user` = '$ku[id]', `id_plant` = '0', `soil` = '0',`time` = '0',`time_water` = '0',`time_soil` = '0',`cultivator` = '0',`first` = '0'");
$plants=1;
}
if($rrc==2000)
{
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `type` = 'rubies',  `time` = '$time', `count` = '2000'");
mysql_query("UPDATE `kolhoz_collective` SET `rubies` = '".($mc['rubies']+2000)."' WHERE `id` = '$mc[id]'");

$prec=1;
}
if($rrc1==200 || $rrc1==360 || $rrc1==900 || $rrc1==1000)
{
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `type` = 'rubies',  `time` = '$time', `count` = '1000'");
mysql_query("UPDATE `kolhoz_collective` SET `rubies` = '".($mc['rubies']+1000)."' WHERE `id` = '$mc[id]'");

$prec1=1;
}
if($rrc2==20 || $rrc2==30 || $rrc2==90 || $rrc2==100)
{
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `type` = 'rubies',  `time` = '$time', `count` = '20'");
mysql_query("UPDATE `kolhoz_collective` SET `rubies` = '".($mc['rubies']+20)."' WHERE `id` = '$mc[id]'");
$prec2=1;
}

if($rya==10 || $rya==40 || $rya==70 || $rya==100)
{
$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;
}
if($rd==10 || $rd==40 || $rd==70 || $rd==100)
{
$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;
}
if($rg==10 || $rg==40 || $rg==70 || $rg==100)
{
$timee=10800;
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku['time_drakon']>$time?"".($ku['time_drakon']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku['time_yastreb']>$time?"".($ku['time_yastreb']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku['time_shmel']>$time?"".($ku['time_shmel']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");

$rge=1;
}
if($rsc==10 || $rsc==40 || $rsc==70 || $rsc==100)
{
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = '".($ku['scarecrow_time']>$time?"".($ku['scarecrow_time']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time_lottery` = '".($ku['scarecrow_time_lottery']>$time?"".($ku['scarecrow_time_lottery']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");

$rsce=1;
}
if($rsc1==10 || $rsc1==40 || $rsc1==70 || $rsc1==100)
{
$timee=36000;
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = '".($ku['scarecrow_time']>$time?"".($ku['scarecrow_time']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");

$rsce1=1;
}
if($rsc2==500 || $rsc2==980 || $rsc2==1000 || $rsc3==4000)
{
$timee=360000;
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = '".($ku['scarecrow_time']>$time?"".($ku['scarecrow_time']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");

$rsce2=1;
}
if($rr==5000 || $rr==7500 || $rr==9800 || $rr==10300)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+10000)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_lottery` SET `nick` = '$ku[nick]', `present` = '10000', `time` = '$time', `id_user` = '$ku[id]'");
$pre=1;
}
if($rr2==5000 || $rr2==7500 || $rr2==9800 || $rr2==10300)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+5000)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_lottery` SET `nick` = '$ku[nick]', `present` = '5000', `time` = '$time'");
$pre1=1;
}
if($rr3==1800 || $rr3==2200 || $rr3==2300 || $rr3==2500)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+2000)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_lottery` SET `nick` = '$ku[nick]', `present` = '2000', `time` = '$time', `id_user` = '$ku[id]'");
$pre2=1;
}
if($rr4==150 || $rr4==160 || $rr4==170 || $rr4==180)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+1000)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_lottery` SET `nick` = '$ku[nick]', `present` = '1000', `time` = '$time', `id_user` = '$ku[id]'");
$pre3=1;
}
if($rr5==200 || $rr5==210 || $rr5==220 || $rr5==230)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+100)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_lottery` SET `nick` = '$ku[nick]', `present` = '100', `time` = '$time', `id_user` = '$ku[id]'");
$pre4=1;
}
if($rr6==10 || $rr6==90 || $rr6==200 || $rr6==250)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+10)."' WHERE `id` = '$ku[id]'");
$pre5=1;
}
if($rhp==10 || $rhp==40 || $rhp==70 || $rhp==100)
{
$timee=3600;
$ps=500;
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]'");
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time_lottery` = '".($ku['hydropinics_time_lottery']>$time?"".($ku['hydropinics_time_lottery']+$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_money']=$money-$ku['money'];
header("Location:?lottery");
}
}
echo "<div class='input_button'><center>Лотерея ''Спринт''</center></div>";
echo "<div class='content'><div class='blockings'>";
echo "<ul><li><img width='16' height='16' src='images/icons/ticket.png' alt='o'>
<a href='?lottery&start=1'>Купить билет</a> <span><img width='16' height='16' src='images/icons/money.png' alt='o'> <span class='title'>10'000'000</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'>3.0m</span><span class='minor'> (<span>3000000</span>)</span></span></li>";

if(isset($pre))echo "<li><span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>10'000</span></li>";
echo "<li></li></ul></span></li>";
if(isset($pre1))echo "<li><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>5'000</span></li>";
echo "<li></li></ul></span></li>";
if(isset($pre2))echo "<li><span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>2'000</span></li>";
echo "<li></li></ul></span></li>";
if(isset($pre3))echo "<li><span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>1'000</span></li>";
echo "<li></li></ul></span></li>";
if(isset($pre4))echo "<li><span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>100</span></li>";
echo "<li></li></ul></span></li>";
if(isset($pre5))echo "<li><span><img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span class='title'>10</span></li>";
echo "<li></li></ul></span></li>";
if(isset($prec))echo "<li><span>В колхозную кассу от вашего имени добавляется <img width='16' height='16' src='images/icons/ruby.png' alt='o'><span class='title'>2'000</span></li>";
echo "<li></li></ul></span></li>";
if(isset($prec1))echo "<li><span>В колхозную кассу от вашего имени добавляется <img width='16' height='16' src='images/icons/ruby.png' alt='o'><span class='title'>1'000</span></li>";
echo "<li></li></ul></span></li>";
if(isset($prec2))echo "<li><span>В колхозную кассу от вашего имени добавляется <img width='16' height='16' src='images/icons/ruby.png' alt='o'><span class='title'>20</span></li>";
echo "<li></li></ul></span></li>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"),0)<98)
if(isset($pets))echo "<li><span><img src='img/pets/$random.png' alt='o'> Новый загон с животным <span class='title'>".hsc($pet['name'])."</span>!</li>";
echo "<li></li></ul></span></li>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0)<98)
if(isset($plants))echo "<li><span><img src='img/dirt_new.jpg' alt='o'> <span class='title'> Новая грядка</span>!</li>";
echo "<li></li></ul></span></li>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]'"),0)<98)
if(isset($peta))echo "<li><span><img src='img/dirt_new.jpg' alt='o'> <span class='title'> Новая загон</span>!</li>";
echo "<li></li></ul></span></li>";
if(isset($rosek))echo "<li><span><img width='48' height='48' src='images/plants/55.png' alt='o'> <span class='epic'> Розы</span> <span class='title'>1000000 штук</span></li>";

if(isset($rsce1))echo "<li><span><img src='img/scarecrow.png' alt='o'><span class='epic'> Пугало</span> на <span class='title'>10 часов!</span></li>";
if(isset($rsce2))echo "<li><span><img width='16' height='16' src='images/icons/scarecrow.png' alt='o'><span class='epic'> Пугало</span> на <span class='title'>4 дня 4 часа!</span></li>";

if(isset($rsce))echo "<li><span><img width='16' height='16' src='images/icons/scarecrow.png' alt='o'><span class='epic'> Пугало</span> на <span class='title'>1 час!</span></li>"; 
if(isset($rhpe))echo "<li><span><img width='16' height='16' src='images/icons/hidropinics.png' alt='o'> <span class='epic'> Гидропоника</span> на <span class='title'>1 час!</span> <br/>Итого: <span class='title'>+500%</span> на <span class='title'>".time_left($ku['hydropinics_time']-$time)."</span></li></li>";
if(isset($rshe))echo "<li><span><img width='16' height='16' src='images/icons/heli1n.png' alt='o'> Эффект от вертолета <span class='epic'>Шмель</span> на <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='epic'>Ястреб</span> на <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='epic'>Дракон</span> на <span class='title'>1 час!</span></li>";
if(isset($rge))echo "<li><span><img src='img/grom1.png' alt='o'> Эффект от вертолета  <span class='epic'>Гром</span> на <span class='title'>3 часа!</span></li>";

}
echo '<br>Последние Победители:<br>';
$result = mysql_query("SELECT * FROM `kolhoz_lottery` ORDER BY `time` DESC LIMIT 5");
while($msg = mysql_fetch_assoc($result)){
echo''.date('d.m.Y в H:i', $msg['time']).' игрок <a href="?user='.($msg['id_user']).'"><span>'.($msg['nick']).'</span></a> выиграл <img width="16" height="16" src="img/icons/ruby.png" alt="o"><span class="title">'.number_format($msg[present]).' </span><br/>';
}
?>
<?
echo "<li class='pt minor'>Лотерея - беспроигрышная, минимальный выигрыш <img width='16' height='16' src='img/icons/experience.png' alt='o'> 3000000.</li></li>";

echo "</ul></div>";


?>
<?
include_once 'inc/foot.php';
?>