Файл: zfarm.mobi/inc/petfarm/money.php
Строк: 105
<?
include_once '../system/config.php';
if(isset($_GET['money']) && intval($_GET['money'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id` = '".intval($_GET['money'])."' AND `id_user` = '$ku[id]' AND `id_pet` != '0'"),0)!=0)
{
$petground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id` = '".intval($_GET['money'])."' AND `id_user` = '$ku[id]'"),0);
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$petground[id_pet]'"));
$d_money=floor($petground['time_money2']/(4*3600));
if($d_money>0)
{
$nt=$petground['time_money2']-($d_money*14400);
$count=1;
$count_conveyor_act=0;
$count_vet_act=0;
$mc_count=0;
if(isset($conveyor_act))$count_conveyor_act=($count/100)*$conveyor_act;
if(isset($vet_act))$count_vet_act=($count/100)*$vet_ps_m;
if(isset($mc))$mc_count=($count/100)*($mc['level']*10);
$count=$count_conveyor_act+$count_vet_act+$count+$mc_count;
$money=($count*$pet['money'])*$d_money;
$assUser = mysql_fetch_array(mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '$ku[id]'"));
$ass = mysql_fetch_array(mysql_query("SELECT * FROM `assignments` WHERE `id` = '$assUser[assignment]'"));
$assignment=($pet['count']*$d_money);
if($pet['id']==$ass['pet1'] && $assUser['assignment']>0)
{
mysql_query("UPDATE `assignments_user` SET `pet1` = '".($assUser['pet1']+$assignment)."' WHERE `id_user` = '$ku[id]'");
}
if($pet['id']==$ass['pet2'] && $assUser['assignment']>0)
{
mysql_query("UPDATE `assignments_user` SET `pet2` = '".($assUser['pet2']+$assignment)."' WHERE `id_user` = '$ku[id]'");
}
if($pet['id']==$ass['pet3'] && $assUser['assignment']>0)
{
mysql_query("UPDATE `assignments_user` SET `pet3` = '".($assUser['pet3']+$assignment)."' WHERE `id_user` = '$ku[id]'");
}
mysql_query("UPDATE `kolhoz_petground` SET `time_money` = '$time', `time_money2` = '$nt' WHERE `id` = '$petground[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$money)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '$money' WHERE `id` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$nmoney=floor(($money/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$money-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$nmoney', `type` = 'money', `time` = '$time'");
}
}
header("Location:/barnyard");
exit;
}
?>