Файл: zfarm.mobi/inc/collective/hangar.php
Строк: 176
<?
$title='Ангар';
include_once '../system/config.php';
$mcu =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$ct =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '".intval($_GET['hangar'])."'"));
if(isset($_GET['hangar']) && ($_GET['hangar'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective` WHERE `id` = '".($_GET['hangar'])."' LIMIT 1"),0)!=0){
if(isset($_GET['gaz']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0' AND `id` = '".intval($_GET['gaz'])."'"),0)!=0 && isset($mc) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0' AND `id` = '".intval($_GET['gaz'])."'"));
$heli['max_gaz']=250;
if($heli['heli']==1)
{
$heli['name']='Шмель';
}
elseif($heli['heli']==2)
{
$heli['name']='Ястреб';
}
elseif($heli['heli']==3)
{
$heli['max_gaz']=500;
$heli['name']='Дракон';
}
elseif($heli['heli']==4)
{
$heli['max_gaz']=2500;
$heli['name']='Гром';
}
$gaz2=$heli['max_gaz']-$heli['gaz'];
$cena=$gaz2*1000;
if(isset($_GET['ok']))
{
if($mc['money']>=$cena)
{
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli['gaz']+$gaz2)."' WHERE `id` = '$heli[id]'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']-$cena)."' WHERE `id` = '$mc[id]'");
$mc['money']=$mc['money']-$cena;
}
else no_money_mc($cena-$mc['money']);
}
else
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Подтверждение</h2></div><div class="content"><ul class="block"><li><span>Заправка вертолёта '.$heli['name'].'-'.$heli['id'].' ('.$gaz2.'т)</span><br/><span>цена</span>: <span><img src="/img/icons/money.png" alt="o"><span >'.$gaz2.' тыс.</span></span></li><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="/kolhoz/hangar/'.$ct['id'].'//gaz/'.$heli['id'].'/ok"><span>Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/kolhoz/hangar/'.$ct['id'].'/"><span>
Нет, отказываюсь</span></a></li></ul>';
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
}
if(isset($_GET['arend']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0' AND `id` = '".intval($_GET['arend'])."'"),0)!=0 && isset($mc) && $mc['id']==$ct['id'])
{
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0' AND `id` = '".intval($_GET['arend'])."'"));
$gaz=10;
if($heli['heli']==4)$gaz=25;
if($heli['gaz']>=$gaz)
{
$arend=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '$heli[heli]'"));
if(!$arend || $arend['time']<$time)
{
if($heli['heli']==4)$type=9;else $type=7;
$count_tt=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` = '$heli[heli]'"),0);
$tl=round($mc['users']/($type*$count_tt),2);
$t2=0;
if($tl2=explode('.',$tl))
{
if(strlen2($tl2[1])<2)$tl2[1]=$tl2[1]."0";
$t1=$tl2[0];
$tl2=$tl2[1];
$dil=100/60;
$t2=floor($tl2/$dil);
}
$nt=$time+($t1*3600)+($t2*60);
if(!$arend)mysql_query("INSERT INTO `kolhoz_collective_ahlist` SET `id_user` = '$ku[id]', `heli` = '$heli[heli]', `time` = '$nt'");
else mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt' WHERE `id` = '$arend[id]'");
if($heli['heli']==4)
{
$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_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
}
else
{
if($heli['heli']==1)$htype='shmel';
elseif($heli['heli']==2)$htype='yastreb';
else $htype='drakon';
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_$htype` = '".($ku["time_$htype"]>$time?"".($ku["time_$htype"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
}
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli['gaz']-$gaz)."' WHERE `id` = '$heli[id]'");
}
}
}
if(isset($_GET['buy_place']) && $mcu['status']==1)
{
$cena=1000000;
if($ct['money']>=$cena)
{
if(isset($_GET['ok']))
{
mysql_query("INSERT INTO `kolhoz_collective_heli` SET `id_collective` = '$ct[id]', `id_user` = '$ku[id]', `time` = '$time', `heli` = '0'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($ct['money']-$cena)."' WHERE `id` = '$ct[id]'");
}
else
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Подтверждение</h2></div><div class="content"><ul class="block"><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="/kolhoz/hangar/'.$ct['id'].'//BuyPlace/ok"><span>Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/kolhoz/hangar/'.$ct['id'].'/"><span>
Нет, отказываюсь</span></a></li></ul>';
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
}
else no_money_ct($cena-$mc['money']);
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/kolhoz/$ct[id]'>".hsc($ct['name'])."</a> / Ангар</h2></div>
<div class='content'>
<div class='div'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0' ORDER BY `time` ASC LIMIT $start, $set[p_str]");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
$post['max_gaz']=250;
if($post['heli']==1)
{
$img='bumblebee1.png';
$post['name']='Шмель';
}
elseif($post['heli']==2)
{
$img='hawk1.png';
$post['name']='Ястреб';
}
elseif($post['heli']==3)
{
$post['max_gaz']=500;
$img='dragon1.png';
$post['name']='Дракон';
}
elseif($post['heli']==4)
{
$post['max_gaz']=2500;
$img='grom1.png';
$post['name']='Гром';
}
echo "<li><span>n
<img width='64' height='64' src='/img/$img' alt='o' class='portrait'>n
<ul>n
<li><span class='epic'><span>".hsc($post['name'])."</span>-<span>$post[id]</span></span></li>n
<li>Топливо: <span>$post[gaz]</span>/<span>$post[max_gaz]</span>тn
</li>n";
$arend=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '$post[heli]'"));
if(($post['heli']==4 && $post['gaz']>=25 || $post['heli']<=3 && $post['gaz']>=10) && isset($mc) && $mc['id']==$ct['id'])
{
echo "<li>n";
if(!$arend || $arend['time']<$time)
{
echo "<a href='/kolhoz/hangar/$ct[id]/arend/$post[id]/page/$page'><span>Вызвать себе</span></a>";
}
else echo "Вызов будет доступен через <span>".time_left($arend['time']-$time)."</span>n";
echo "</li>n";
}
if($post['gaz']<$post['max_gaz'] && $ct['id']==$mc['id'] && isset($mc) && $mcu['status']<=3)echo "<a href='/kolhoz/hangar/$ct[id]/gaz/$post[id]'><span>Заправить</span></a>";
echo "</ul>n
<div style='clear:both'></div>n
</span></li>n";
}
if ($k_page>1)str("/kolhoz/hangar/$ct[id]/",$k_page,$page); // Вывод страниц
$count_heli=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]' AND `heli` != '0'"),0);
$count_places=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$ct[id]'"),0);
?>
<div>
<img width='64' height='64' src='/img/heli_place2.png' alt='o' class='portrait'>
<ul>
<li>Площадки: <span ><? echo $count_heli;?></span>/<span ><? echo $count_places;?></span></li>
<?
if($mcu['status']==1 && $mc['id']==$ct['id'])echo "<li><a href='/kolhoz/hangar/$ct[id]/BuyPlace'>Купить площадку</a></li>";
?>
</ul>
<div style="clear:both"></div>
</div>
<div>
<img width="64" height="64" src="/img/station.png"
alt="o" class="portrait">
<ul>
<li><a href="/kolhoz/station/<? echo $ct['id'];?>/">Заправка</a></li>
</ul>
<div style="clear:both"></div>
</div>
<ul>
<li><a href="/shop/helicopter/1">Купить "Шмель"</a></li>
<li><a href="/shop/helicopter/2">Купить "Ястреб"</a></li>
<li><a href="/shop/helicopter/3">Купить "Дракон"</a></li>
<li><a href="/shop/helicopter/4">Купить "Гром"</a></li>
</ul>
<div class="minor pt">
Ангар - колхозная постройка для управления вертолётами.<br/>
Вертолёты летают на фермы к колхозникам и оставляют бонусы, увеличивающие результативность грядок и загонов фермера!<br>Подробности читайте в описании вертолётов.
</div>
</div>
<?
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
?>