<?
error_reporting(E_ALL^E_NOTICE);
if(isset($_GET['myfarm']) && isset($_GET['change_soil']))
{
echo '<div class="event"><h1>Магазин удобрений</h1></div>';
echo "<div class='content'>";
echo "<div class='block'>";

if(isset($_GET['select']) && intval($_GET['select'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '".intval($_GET['select'])."' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
{
mysql_query("UPDATE `kolhoz_user` SET `last_soil` = '".intval($_GET['select'])."' WHERE `id` = '$ku[id]'");
header("Location:/myfarm/".passgen());
exit;
}
if(isset($_GET['info'])){
$soil=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil` WHERE `id` = '".intval($_GET['info'])."'"));
$rat=$soil['rating'];
$rat_sc_act=0;
$rat_dog_act=0;
$rat_hp_act=0;
$rat_mc_hp_act=0;
$rat_drakon_act=0;
$rat_soiler_act=0;
$rat_cultivator_seat_soil=0;
$rat_school_act=0;
$rat_dog_act=0;
$rat_lib_act=0;
$arena_rat=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($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($soiler_act))$rat_soiler_act=(($rat/100)*$soiler_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_act=$rat_soiler_act*2;
if(isset($shmel_act))$rat_hp_act=$rat_hp_act*2;
if(isset($cultivator_seat_soil))$rat_cultivator_seat_soil=(($rat/100)*$cultivator_seat_soil);
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));
$ratt=$rat+$rat_mc_hp_act+$rat_sc_act+$rat_hp_act+$rat_drakon_act+$rat_soiler_act+$rat_school_act+$rat_lib_act+$rat_cultivator_seat_soil+$rat_dog_act+$arena_rat;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;

$st=$soil['time'];
$st_hp_act=0;
$st_mc_hp_act=0;
$st_soiler_act=0;
if($ku['lfertilizer']>0)$lfertilizer=($st/100)*($ku['lfertilizer']*7); 

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+$lfertilizer+$st_soiler_act+$st+$st_mc_hp_act;
}
echo "<h3>Выбери Удобрение</h3>";
$q=mysql_query("SELECT * FROM `kolhoz_soil`");
echo "<ul>";
if(!isset($_GET['info']))$_GET['info']='';
while($post=mysql_fetch_array($q))
{
echo "<li style='padding-bottom:8px'>";
echo "<img width='48' height='48' src='images/soils/$post[id].png' alt='o' class='portrait'><div>".($ku['level']>=$post['level']?"<a href='/myfarm/change_soil/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><br/>".(intval($_GET['info'])!=$post['id']?"<a class='small minor' href='/myfarm/change_soil/info-$post[id]'>Подробнее</a>":"<div class='minor pb'>
<ul><li><span class='minor'>Суммарный опыт:</span><span class='title'>
<img width='16' height='16' src='images/icons/experience.png' alt=''/><span>".(floor($rat))."</span></span></li>
<li><span class='minor'>Вместе с бонусами ускоряет рост на: </span><span class='title'><span>".time_left($st)."</span></span></li>
</ul></div>")."</div><div style='clear:both'></div></li>";
}
echo "</ul></div>";
include_once 'inc/foot.php';
}
?>