Вход Регистрация
Файл: inc/system/heli_all.php
Строк: 71
<?
$mcu
=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '".$ku['id']."'"));
$mc=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '".$mcu['id_collective']."'"));
$mc['users']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_collective` = '".$mc['id']."'"),0);

$heli_s_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1'"),0);
$heli_y_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2'"),0);
$heli_d_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3'"),0);
$heli_g_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '4'"),0);
$arend_s=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '1'"));
$arend_y=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '2'"));
$arend_d=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '3'"));
$arend_g=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '4'"));

if(isset(
$_GET['heli_all']))
{
    if((
$ku["time_shmel"]<($time+7200)) && $heli_s_ct != '0' && $arend_s['time']<$time)
    {
        
$type1=7;
        
$count_tt1=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1'"),0);
        
$tl1=round($mc['users']/($type1*$count_tt1),2);
        
$t21=0;
        if(
$tl21=explode('.',$tl1))
        {
            if(
strlen2($tl21[1])<2)$tl21[1]=$tl21[1]."0";
            
$t11=$tl21[0];
            
$tl21=$tl21[1];
            
$dil1=100/60;
            
$t21=floor($tl21/$dil1);
        }
        
$nt1=$time+($t11*3600)+($t21*60);
        
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '".$nt1."' WHERE `id` = '".$arend_s['id']."'");
        
$timee1=3600;
        
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee1)."":"".($time+$timee1)."")."' WHERE `id` = '".$ku['id']."'");
        
$heli1=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1' AND `gaz` > '10'"));
        
$gaz1=10;
        if(!
$heli1)
        {
            
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli1['gaz']-$gaz1)."' WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1' LIMIT 1");
        }
    }

    if((
$ku["time_yastreb"]<($time+7200)) && $heli_y_ct != '0' && $arend_y['time']<$time)
    {
        
$type2=7;
        
$count_tt2=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2'"),0);
        
$tl2=round($mc['users']/($type2*$count_tt2),2);
        
$t22=0;
        if(
$tl22=explode('.',$tl2))
        {
            if(
strlen2($tl22[1])<2)$tl22[1]=$tl22[1]."0";
            
$t12=$tl22[0];
            
$tl22=$tl22[1];
            
$dil2=100/60;
            
$t22=floor($tl22/$dil2);
        }
        
$nt2=$time+($t12*3600)+($t22*60);
        
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '".$nt2."' WHERE `id` = '".$arend_y['id']."'");
        
$timee2=3600;
        
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee2)."":"".($time+$timee2)."")."' WHERE `id` = '".$ku['id']."'");
        
$heli2=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2' AND `gaz` > '10'"));
        
$gaz2=10;
        if(!
$heli2)
        {
            
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli2['gaz']-$gaz2)."' WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2' LIMIT 1");
        }
    }
    if((
$ku["time_drakon"]<($time+7200)) && $heli_d_ct != '0' && $arend_d['time']<$time)
    {
        
$type3=7;
        
$count_tt3=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3'"),0);
        
$tl3=round($mc['users']/($type3*$count_tt3),2);
        
$t23=0;
        if(
$tl23=explode('.',$tl3))
        {
            if(
strlen2($tl23[1])<2)$tl23[1]=$tl23[1]."0";
            
$t13=$tl23[0];
            
$tl23=$tl23[1];
            
$dil3=100/60;
            
$t23=floor($tl23/$dil3);
        }
        
$nt3=$time+($t13*3600)+($t23*60);
        
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '".$nt3."' WHERE `id` = '".$arend_d['id']."'");
        
$timee3=3600;
        
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee3)."":"".($time+$timee3)."")."' WHERE `id` = '".$ku['id']."'");
        
$heli3=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3' AND `gaz` > '10'"));
        
$gaz3=10;
        if(!
$heli3)
        {
            
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli3['gaz']-$gaz3)."' WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3' LIMIT 1");
        }
    }
    if
    (
        (
            (
$heli_s_ct=='0' || $arend_s['time'] > $time)
                && 
            (
$heli_y_ct=='0' || $arend_y['time'] > $time)
                &&
            (
$heli_d_ct=='0' || $arend_d['time'] > $time)
        )  
            && 
        (
                (
                    
$ku["time_shmel"]<($time+7200
                        || 
                    
$ku["time_yastreb"]<($time+7200
                        || 
                    
$ku["time_drakon"]<($time+7200)
                )
            && 
                    
$heli_g_ct != '0' && $arend_g['time']<$time
        
)
    )
    {
        
$type4=7;
        
$count_tt4=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '4'"),0);
        
$tl4=round($mc['users']/($type4*$count_tt4),2);
        
$t24=0;
        if(
$tl24=explode('.',$tl4))
        {
            if(
strlen2($tl24[1])<2)$tl24[1]=$tl24[1]."0";
            
$t14=$tl24[0];
            
$tl24=$tl24[1];
            
$dil4=100/60;
            
$t24=floor($tl24/$dil4);
        }
        
$nt4=$time+($t14*3600)+($t24*60);
        
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt4' WHERE `id` = '$arend_g[id]'");
        
$timee4=3601;
        if(
$ku["time_shmel"]<($time+7200))
        {
            
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee4)."":"".($time+$timee4)."")."' WHERE `id` = '$ku[id]'");
        }
        if(
$ku["time_yastreb"]<($time+7200))
        {
            
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee4)."":"".($time+$timee4)."")."' WHERE `id` = '$ku[id]'");
        }
        if(
$ku["time_drakon"]<($time+7200))
        {
            
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee4)."":"".($time+$timee4)."")."' WHERE `id` = '$ku[id]'");
        }
        
$heli4=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '4' AND `gaz` > '10'"));
        
$gaz4=10;
        if(!
$heli4)
        {
            
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli4['gaz']-$gaz4)."' WHERE `id_collective` = '$mc[id]' AND `heli` = '4' LIMIT 1");
        }

    } 
      
header("Location:/".$link);
}



function 
heliCall($link)
{
    global 
$ku$time;

    
$mcu=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '".$ku['id']."'"));
    
$mc=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '".$mcu['id_collective']."'"));
    
$mc['users']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_collective` = '".$mc['id']."'"),0);

    
$heli_s_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1'"),0);
    
$heli_y_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2'"),0);
    
$heli_d_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3'"),0);
    
$heli_g_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '4'"),0);
    
$arend_s=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '1'"));
    
$arend_y=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '2'"));
    
$arend_d=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '3'"));
    
$arend_g=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '4'"));


    if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"),0)!=0)
    {
        echo 
"<li class='pt'><img width='16' height='16' src='/img/grom1.png' alt='o'> <a href='/kolhoz/hangar/$mc[id]/'>Вызвать вертолет</a></li>";
        if(
                ((
$ku["time_shmel"]<($time+7200)) && $heli_s_ct != '0' &&  $arend_s['time']<$time
                    || 
                ((
$ku["time_yastreb"]<($time+7200)) && $heli_y_ct != '0' && $arend_y['time']<$time
                    || 
                ((
$ku["time_drakon"]<($time+7200)) && $heli_d_ct != '0' &&  $arend_d['time']<$time)    
                    ||
                (
                    (
                        (
$heli_s_ct=='0' || $arend_s['time'] > $time)
                            && 
                        (
$heli_y_ct=='0' || $arend_y['time'] > $time)
                            &&
                        (
$heli_d_ct=='0' || $arend_d['time'] > $time)
                    ) 
                        && 
                    (
                        (
                            
$ku["time_shmel"]<($time+7200
                                || 
                            
$ku["time_yastreb"]<($time+7200
                                || 
                            
$ku["time_drakon"]<($time+7200)
                        )
                            && 
                        
$heli_g_ct != '0' && $arend_g['time']<$time
                    

                ) 
            )
        {
            echo 
"<li><img width='16' height='16' src='/img/grom1.png' alt='o'> <a href='/".$link."?heli_all'>Вызвать все вертолеты</a></li>";
        }
    }
    
    

    
}



?>
Онлайн: 1
Реклама