Файл: inc/farm/myfarm.php
Строк: 393
<?
$title='Грядки';
$link='garden';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/config.php';
if(isset($_GET['ok_garden'])){
$rand = mt_rand(1,100);
if($rand <= 2 and $ku['level'] >= 35){
$fantik = mysql_fetch_array(mysql_query("SELECT * FROM `collections` ORDER BY RAND()"));
mysql_query("INSERT INTO `collections_users` SET
`id_user` = '".$ku['id']."',
`name` = '".$fantik['name']."',
`type` = '".$fantik['type']."',
`type_2` = '".$fantik['type_2']."'");
header('Location: /garden?fantik='.$fantik['id']); exit;
}
}
if(isset($_GET['ok_podarok'])){
$req = mysql_query("SELECT * FROM `podarok` WHERE `id_user` = '".$ku['id']."'");
$pod = mysql_fetch_array($req);
if($pod['day'] == 3 and $pod['time'] == date('dm', time())){
$fantik = mysql_fetch_array(mysql_query("SELECT * FROM `collections` WHERE `name` = '".mysql_real_escape_string($_SESSION['fantik'])."'"));
mysql_query("INSERT INTO `collections_users` SET
`id_user` = '".$ku['id']."',
`name` = '".$fantik['name']."',
`type` = '".$fantik['type']."',
`type_2` = '".$fantik['type_2']."'");
mysql_query("UPDATE `podarok` SET `day` = 4, `time` = '".date('dm', time())."' WHERE `id_user` = '".$ku['id']."'");
$_SESSION['fantik'] = '';
header('Location: /garden?fantik='.$fantik['id']); exit;
}
}
if(isset($_GET['fantik'])){
$fantik = mysql_fetch_array(mysql_query("SELECT * FROM `collections` WHERE `id` = '".intval($_GET['fantik'])."'"));
echo '<div class="block"><table><td>
<td><img src="/img/colectibles/'.$fantik['type_2'].'.png"></td>
<td>Вы нашли новый фантик<br /><b>'.$fantik['name'].'</b>
</td></table></div>';
}
if($ku['time_logo'] < time()){
echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/img/garden-animation.jpg">';
}else{
$req = mysql_query("SELECT `img` FROM `logo` WHERE `id` = '".$ku['id_logo']."'");
$logo = mysql_fetch_array($req);
echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/img/logo/'.$logo['img'].'">';
}
if(isset($_GET['gos']))
{
if(isset($mc))
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$gos[id_plant]' AND (`level` = '$ku[level]' OR `level` < '$ku[level]')"),0)!=0)
mysql_query("UPDATE `kolhoz_user` SET `last_plant` = '$gos[id_plant]' WHERE `id` = '$ku[id]'");
header("Location:/garden/");
exit;
}
else err_game("Для начала вступите в колхоз.");
}
if(isset($_GET['close_news'])){
mysql_query("INSERT INTO `close_news` SET `id_user` = '".$ku['id']."', `id_news` = '".intval($_GET['close_news'])."'");
header('Location: ?');
}
$req = mysql_query("SELECT `msg`,`id`,`name` FROM `kolhoz_forum` WHERE `type` = 'tema' and `mother` = 1 ORDER BY `id` DESC LIMIT 1");
$news = mysql_fetch_array($req);
$count = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `close_news` WHERE `id_user` = '".$ku['id']."' and `id_news` = '".$news['id']."'"),0);
if($count == 0){
function cut_msg($text)
{
mb_internal_encoding("UTF-8");
$text = mb_substr($text, 0, 140);
return str_replace(';','',$text);
}
echo '<div class="block"><center><b>'.$news['name'].'</b></center>'.cut_msg(output_text($news['msg'])).'...<br />
<a href="?close_news='.$news['id'].'">Скрыть</a>/<a href="/forum/'.$news['id'].'">Читать</a></div>';
}
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/user/Chest.php';
if(isset($_SESSION['cp']))
{
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelINFO'><span class='feedbackPanelINFO'>Бесплатная очистка грядок будет доступна через ".time_left($ku['time_cp']-$time)."</span></li></ul></div>";
unset($_SESSION['cp']);
}
include'/inc/communication/p_str.php';
echo '<div class="flat-content mb0 bg-brown">';
if($ku['str'] == 5) echo "<div><img src='/img/icons/down.png' alt='o'> <a href='/garden/LinkUserGoUpProfileGetSetting/'>Компактный вид</a></div>";
if($ku['str'] == 50) echo "<div><img src='/img/icons/up.png' alt='o'> <a href='/garden/LinkUserGoDownProfileGetSetting/'>Компактный вид</a></div>";
echo '</div><div class="flat-content">';
if($ku['str'] == 5) { echo "<a href='/garden/'><img src='/img/icons/refresh.png' alt='o'></a> "; }else{ echo "<div><img src='/img/icons/refresh.png' alt='o'> <a href='/garden/'>Обновить</a></div>"; }
if($ku['str'] == 5) {
if($ku['hydropinics_time']>$time)echo "<a class='epic' href='/shop/hydropinics'><img src='/img/icons/hydropinics.png' alt='o'></a> "; }else{ if($ku['hydropinics_time']>$time)echo "<li><img src='/img/icons/hydropinics.png' alt='o'> <a class='epic' href='/shop/hydropinics'>Гидропоника</a><span class='minor'> $ku[hydropinics_type]% на <span>".time_left($ku['hydropinics_time']-$time)."</span></span></li>"; }
if($ku['str'] == 5) {
if($ku['scarecrow_time']>$time)echo "<a class='epic' href='/shop/scarecrow'><img src='/img/icons/scarecrow.png' alt='o'></a> "; }else{ if($ku['scarecrow_time']>$time)echo "<li><img src='/img/icons/scarecrow.png' alt='o'> <a class='epic' href='/shop/scarecrow'>Пугало</a><span class='minor'> на <span>".time_left($ku['scarecrow_time']-$time)."</span></span></li>"; }
if($ku['str'] == 5) {
if($ku['time_shmel']>$time)echo "<a class='epic' href='/shop/helicopter/1'><img alt='o' src='/img/icons/heli1n.png'></a> "; }else{ if($ku['time_shmel']>$time)echo "<li><img alt='o' src='/img/icons/heli1n.png'> <a class='epic' href='/shop/helicopter/1'>Шмель</a><span class='minor'> на <span>".time_left($ku['time_shmel']-$time)."</span></span></li>"; }
if($ku['str'] == 5) {
if($ku['time_yastreb']>$time)echo "<a class='epic' href='/shop/helicopter/2'><img alt='o' src='/img/icons/heli2n.png'></a> "; }else{ if($ku['time_yastreb']>$time)echo "<li><img alt='o' src='/img/icons/heli2n.png'> <a class='epic' href='/shop/helicopter/2'>Ястреб</a><span class='minor'> на <span>".time_left($ku['time_yastreb']-$time)."</span></span></li>"; }
if($ku['str'] == 5) {
if($ku['time_drakon']>$time)echo "<a class='epic' href='/shop/helicopter/3'><img alt='o' src='/img/icons/heli3n.png'></a> "; }else{ if($ku['time_drakon']>$time)echo "<li><img alt='o' src='/img/icons/heli3n.png'> <a class='epic' href='/shop/helicopter/3'>Дракон</a><span class='minor'> на <span>".time_left($ku['time_drakon']-$time)."</span></span></li>"; }
if($ku['str'] == 5)
{
if($ku['garden_yarilo_time']>$time)echo "<a class='epic' href='/shop/garden/id/1'><img alt='o' width='16' height='16' src='/img/icons/garden1.png'></a> ";
}
else
{
if($ku['garden_yarilo_time']>$time)echo "<li><img alt='o' width='16' height='16' src='/img/icons/garden1.png'> <a class='epic' href='/shop/garden/id/1'>Садовник Ярило</a><span class='minor'> на <span>".time_left($ku['garden_yarilo_time']-$time)."</span></span></li>";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'"),0)!=0 && $ku['harvester']>0)echo "<div><img src='/img/icons/harvest.png' alt='o'> <a href='/garden/harvestall/'>Собрать все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `soil` = '0' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_plant` != '0' AND `time` > '$time'"),0)!=0 && $ku['soiler']>0)echo "<div><img src='/img/icons/soil.png' alt='o'> <a href='/garden/soilall/'>Удобрить все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND (`time_water` = '$time' OR `time_water` < '$time') AND `time` > '$time' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')"),0)!=0 && $ku['irregate']>0)echo "<div><img src='/img/icons/water.png' alt='o'> <a href='/garden/waterall'>Полить все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0)!=0 && $ku['seeder']>0)echo "<div><img src='/img/icons/seat.png' alt='o'> <a href='/garden/seatall/'>Засеять все</a></div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'"),0)!=0 && $ku['cultivator']>0)echo "<div><img src='/img/icons/dig.png' alt='o'> <a href='/garden/digall/'>Вскопать все</a></div>";
echo '</div>';
echo "<ul>";
////ГРЯДКИ
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$ku['str']);
$page=page($k_page);
$start=$ku['str']*$page-$ku['str'];
$num=($page-1)*$ku['str'];
$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' ORDER BY `id` DESC LIMIT $start, $ku[str]");
while($post=mysql_fetch_array($q))
{
echo "<li>";
if($post['id_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"),0)!=0)$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
echo '<div class="flat-content mb0 bg-brown">';
echo "<span class='font12 text-bold'>".(!isset($plant)?($post['cultivator']==1?"Земля, готовая к посеву":"Необработанная земля"):hsc($plant['name']))."</span>";
echo '</div><div class="flat-content">';
echo "<img style='border-radius: 5px' width='48' height='48' src='/img/".(!isset($plant)?"".($post['cultivator']==1?"dirt_new.jpg":"dirt2_new.jpg")."":"plants/$plant[img].png")."' alt='o' class='portrait'>";
echo (isset($plant) ? ($post['time']>$time?"<span class='small minor'> Урожай через <span> ".time_left($post['time']-$time)."</span></span>":null) : null);
echo "<div>";
/*
<div class="flat-content mb0 bg-brown">
<span class="font12 text-bold">Курица</span>
</div>*/
if(isset($plant))
{
if($post['time']<=$time)
{
echo "<img src='/img/icons/harvest.png' alt='o'> <a href='/garden/harvest/$post[id]/'>Собрать урожай</a>";
}
else
{
if($ku['last_soil']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"),0)!=0)$ls=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"));
echo "<div class='small minor'>".($post['time_soil']<=$time && $post['soil']==0 && $post['time']>$time?"<img src='/img/icons/soil.png' alt='o'> ".(isset($ls)?"<a href='/garden/fertilizer/$post[id]/select/$ls[id]/'>Применить
<span>".hsc($ls['name'])."</span></a>, <a href='/garden/fertilizer/$post[id]/'><span>выбрать
удобрение</span></a>":"<a href='/garden/fertilizer/$post[id]/'>Удобрить</a>")."":"".($post['soil']==0 && $post['time']>$time?"Удобрение через ".time_left($post['time_soil']-$time)."":null)."")."</div>";
echo "<div class='small minor'>".($post['time_water']>$time && $post['time']>$time?"Полив через ".time_left($post['time_water']-$time)."":"".($post['time']>$time?"".($post['soil']==0 && $post['time_soil']>$time || $post['soil']==1?"<img alt='' src='/img/icons/water.png'> <a href='/garden/water/$post[id]/'>Полить</a>":null)."":null)."")."</div>";
}
}
else
{
echo "<span>";
if($ku['last_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
echo "".($post['cultivator']==1?"<img src='/img/icons/seat.png' alt='o'> ".(isset($lp)?"<a href='/garden/seat/$post[id]/select/$lp[id]/'>Посадить <span>".hsc($lp['name'])."</span></a>, <a href='/garden/seat/$post[id]/'><span>выбрать семена</span></a>":"<a href='/garden/seat/$post[id]/'>Посадить</a>")."":"<img src='/img/icons/dig.png' alt='o'> <a href='/garden/dig/$post[id]/'><span style='n'>Вскопать</span></a>")."";
echo "</span>";
}
if(isset($plant))unset($plant);
echo "</div><div style='clear:both'></div></li>";
}
echo '<div class="flat-content mb0 bg-brown">';
echo '<span class="font12 text-bold">Техника</span></div>';
echo '</div><div class="flat-content">';
if($ku['last_plant']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"),0)!=0)$lp=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
if($ku['last_soil']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"),0)!=0)$ls=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"));
echo'<div style="margin-top:1px"></div>';
echo "<ul class='ptm'><li><img src='/img/icons/seat.png' alt='o'> <a href='/garden/plant/'>Сменить растение</a>: <span>".(isset($lp)?"".hsc($lp['name'])."":"-")."</span></li>";
echo'<div style="margin-top:1px"></div>';
echo "<li><img src='/img/icons/soil.png' alt='o'> <a href='/garden/soil/'>Сменить удобрение</a>: <span>".(isset($ls)?"".hsc($ls['name'])."":"-")."</span></li>";
echo "".($ku['time_cp']>$time?"<li><img src='/img/icons/cross.png' alt='o'> До бесплатной очистки: <span>".time_left($ku['time_cp']-$time)."</span></li><li><span><img src='/img/icons/tick.png' alt='o'> <a href='/garden/clean/'><span>Очистить грядки</span></a>(<span>Стоимость</span>: <span><img src='/img/icons/ruby.png' alt='o'> <span
class='n'>".($ku['count_cp']*10)."</span></span>)</span></li>":"<li><img src='/img/icons/cross.png' alt='o'> <a href='/garden/clean/'>Очистить грядки</a></li>")."</ul>";
echo ''.heliCall('garden').'';
echo '</div>';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0)<40){
echo '<a href="/garden/buyBed/" class="flat-btn1 appleGreen font14">
<span class="btn-img coin"></span><span class="middle">Купить грядку за <span class="nobr"><img src="/img/icons/ruby.png" alt="o"> '.cpg(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]'"),0)).'</span></span>
</a>';
}
echo'<div class="menu-foot">';
if ($k_page>1)str("/garden/",$k_page,$page); // Вывод страниц
echo'</div>';
echo '</ul></div></div>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
?>