Файл: cron/ded.php
Строк: 66
<?php
define('ROOTPATH', realpath(dirname(__FILE__)));
include_once __DIR__.'/connect.php';
include(dirname(__DIR__).'/inc/system/functions.php');
$time=time();
$x=mysql_query("SELECT * FROM `kolhoz_user` WHERE `garden_ded_time` > '".$time."' ");
while($ku=mysql_fetch_array($x))
{
$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);
include(dirname(__DIR__).'/inc/system/tehnika.php');
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `time_count` < '$time' AND `id_pet` != '0'"),0)!=0)
{
$q=mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `time_count` < '$time' AND `id_pet` != '0'");
$ohv=0;
while($post=mysql_fetch_array($q))
{
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$post[id_pet]'"));
if($pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id_plant` = '$pet[id]' AND `pet` = '1'")))
{
mysql_query("UPDATE `kolhoz_warehouse` SET `count` = '".($pw['count']+$pet['count'])."' WHERE `id` = '$pw[id]'");
}
else mysql_query("INSERT INTO `kolhoz_warehouse` SET `id_plant` = '$pet[id]', `id_user` = '$ku[id]', `count` = '$pet[count]', `pet` = '1'");
mysql_query("UPDATE `kolhoz_petground` SET `time_count` = '".($time + $pet['time_count'])."' WHERE `id` = '$post[id]' LIMIT 1");
$ohv=$ohv+$count;
}
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND `time_corm` < '$time' AND `time_count` > '$time'"),0)!=0)
{
$q = mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND `time_corm` < '$time' AND `time_count` > '$time'");
$orat=0;
while($post=mysql_fetch_array($q))
{
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$post[id_pet]'"));
$whCorm=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `arena` = '0' AND `fish` = '0' AND `pet` = '0' AND (`count` = '3' OR `count` > '3')"));
if(isset($whCorm) && $whCorm['count']>=3)
{
$rat=$pet['rating'];
$rat_fooder_act=0;
$rat_sc_act=0;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_vet_act=0;
$rat_lib_act=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($fooder_act))$rat_fooder_act=($rat/100)*(40+(20*$fooder_act));
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($vet_act))$rat_vet_act=($rat/100)*$vet_ps_r;
if(isset($lib_act))$rat_lib_act=$rat*2;
if($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
if(isset($shmel_act))$rat_fooder_act=$rat_fooder_act*2;
$ratt=floor($rat+$rat_fooder_act+$rat_sc_act+$rat_drakon_act+$rat_medal+$rat_school_act+$rat_vet_act+$rat_lib_act);
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if(isset($exp3))$rat=$rat*3;
$orat=$orat+$rat;
mysql_query("UPDATE `kolhoz_user` SET `kormer` = '".($ku['kormer']+1)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_petground` SET `time_corm` = '".($time + 3600)."' WHERE `id` = '$post[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_warehouse` SET `count` = '".($whCorm['count']-3)."' WHERE `id` = '$whCorm[id]' AND `arena` = '0' AND `pet` = '0' AND `fish` = '0' LIMIT 1");
}
else
{
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
}
}
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND `time_corm` > '$time' AND `time_water` < '$time' AND `time_water` < `time_corm`"),0)!=0)
{
$q = mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND `time_corm` > '$time' AND `time_water` < '$time' AND `time_water` < `time_corm`");
$orat=0;
while($post=mysql_fetch_array($q))
{
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$post[id_pet]'"));
$rat=$ku['level'];
$rat_feeder_act=0;
$rat_sc_act=0;
$rat_drakon_act=0;
$rat_school_act=0;
$rat_vet_act=0;
$rat_lib_act=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
//if(isset($feeder_act))$rat_feeder_act=(($rat/100)*$feeder_act);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($vet_act))$rat_vet_act=($rat/100)*$vet_ps_r;
if(isset($lib_act))$rat_lib_act=$rat*2;
if($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
if(isset($shmel_act))$rat_feeder_act=$rat_feeder_act*2;
$ratt=floor($rat+$rat_feeder_act+$rat_sc_act+$rat_drakon_act+$rat_medal+$rat_school_act+$rat_vet_act+$rat_lib_act);
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if(isset($exp3))$rat=$rat*3;
$orat=$orat+$rat;
echo "$rat";
mysql_query("UPDATE `kolhoz_petground` SET `time_water` = '".($time + 1800)."' WHERE `id` = '$post[id]' LIMIT 1");
}
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
}
}
?>