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