Файл: inc/petfarm/harv.php
Строк: 55
<?
include_once '../system/config.php';
if (isset($_GET['harv']) && intval($_GET['harv'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id` = '".intval($_GET['harv'])."' AND `id_user` = '$ ku[id]' AND `id_pet` != '0' AND `time_count` < '$ time'"),0)!=0)
{
$petground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_petground` WHERE `id` = '".intval($_GET['harv'])."' AND `id_user` = '$ ku[id]'"),0);
$pet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_pet` WHERE `id` = '$ petground[id_pet]'"));
if($petground['time_count'] < $time)
{
$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_count` = '".($time + $pet['time_count'])."' WHERE `id` = '$petground[id]' LIMIT 1");
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'");
}
}
header("Location:/barnyard");
exit;
?>