<?
if(isset($_GET['sh_myfarm']) && isset($_GET['sh_soil']) && intval($_GET['sh_soil'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_ground_sh` WHERE `id` = '".intval($_GET['sh_soil'])."' AND `id_user` = '$ku[id]'"),0)!=0)
{
echo '<div class="event"><h1>Меню закусочной</h1></div>';
echo "<div class='content'>";
echo "<div class='block'>";
$ground=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_ground_sh` WHERE `id` = '".intval($_GET['sh_soil'])."' AND `id_user` = '$ku[id]'"));
$plant=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_plant_sh` WHERE `id` = '$ground[id_plant]'"));
if($ground['soil']==0 && $ground['time_soil']<=$time && $ground['id_plant']!=0 && $ground['time']>$time)
{
if(isset($_GET['select']) && intval($_GET['select'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_soil_sh` WHERE `id` = '".intval($_GET['select'])."' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
{
$soil=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_soil_sh` WHERE `id` = '".intval($_GET['select'])."'"));
if($ku['money']>=$soil['cena'])
{
$rat=$soil['rating'];

$rat_sc_act=0;
$rat_hp_act=0;
$rat_mc_hp_act=0;
$rat_drakon_act=0;
$rat_soiler_sh_act=0;
$rat_school_act=0;
$rat_lib_act=0;
if(isset($hp_act))$rat_hp_act=(($rat/100)*$hp_ps);
if(isset($mc_hp_act))$rat_mc_hp_act=(($rat/100)*$mc_hp_ps);
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($soiler_sh_act))$rat_soiler_sh_act=(($rat/100)*$soiler_sh_act);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
if(isset($shmel_act))$rat_soiler_sh_act=$rat_soiler_act*2;
if(isset($shmel_act))$rat_hp_act=$rat_hp_act*2;
$ratt=$rat_mc_hp_act+$rat_sc_act+$rat_hp_act+$rat_drakon_act+$rat_soiler_sh_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;

if(isset($dexp))$rat=$rat*2;

$st=$soil['time'];
/*
$st_hp_act=0;
$st_mc_hp_act=0;
$st_soiler_act=0;
if(isset($hp_act))$st_hp_act=($st/100)*$hp_ps;
if(isset($mc_hp_act))$st_mc_hp_act=($st/100)*$mc_hp_ps;
if($soiler_act)$st_soiler_act=($st/100)*$soiler_act;
$st=$st_hp_act+$st_soiler_act+$st+$st_mc_hp_act;
*/
mysql_querll("UPDATE `kolhoz_ground_sh` SET `time` = '".($ground['time']-$st)."', `soil` = '1' WHERE `id` = '$ground[id]' LIMIT 1");
mysql_querll("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$soil['cena'])."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `last_soil_sh` = '$soil[id]' WHERE `id` = '$ku[id]'");
mysql_querll("UPDATE `kolhoz_user` SET `agronom` = '".($ku['agronom']+1)."' WHERE `id` = '$ku[id]'");
$_SESSION['rating']=$rat;
update_mc($rat);
}
else
{
$nm=$soil['cena']-$ku['money'];
$_SESSION['no_money']=$nm;
}
header("Location:?sh_myfarm".$peremenn."&".passgen());
exit;
}
echo "<div><img width='48' height='48' src='images/shaht/$plant[id].png' alt='o' class='portrait'><div class='title'>".hsc($plant['name'])."</div><div class='small minor'>(Добыча через <span>".time_left($ground['time']-$time)."</span>)</div><div style='clear:both'></div></div><h3>Выбери еду для шахтера</h3>";
$q=mysql_querll("SELECT * FROM `kolhoz_soil_sh`");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
echo "<li style='padding-bottom:8px'>";
echo "<img width='48' height='48' src='images/shaht/soil/$post[id].png' alt='o' class='portrait'><div>".($ku['level']>=$post['level']?"<a href='?sh_myfarm".$peremenn."&sh_soil=$ground[id]&select=$post[id]'>":null)."<span>".hsc($post['name'])."</span>".($ku['level']>=$post['level']?"</a>":null)."<span class='minor'>, ".($ku['level']>=$post['level']?"цена: </span><span><img width='16' height='16' src='images/icons/money.png' alt='o'><span class='title'>$post[cena]</span></span>":"доступно с $post[level] уровня</span>")."</div><div class='minor small'>Ускоряет добычу на <span class='title'>".time_left($post['time'])."</span>,опыт: <img width='16' height='16' src='images/icons/experience.png' alt='o'> <span class='title'>$post[rating]</span></div><div style='clear:both'></div></li>";
}
echo "</ul></div>";
include_once 'inc/foot.php';
}
}
?>