<?
if(isset($_GET['level']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_garden` WHERE `id` = '".intval($_GET['level'])."' AND `id_user` = '$ku[id]' AND `id_pet` != '0' AND `level` < '20'"),0)!=0)
{
$petground=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_garden` WHERE `id` = '".intval($_GET['level'])."' AND `id_user` = '$ku[id]' AND `id_pet` != '0' AND `level` < '20'"));
$petground['next_level']=$petground['level']+1;
$money_level=$petground['next_level']*1000;
if(!empty($id_action) AND $id_action==1)$money_level=round($money_level/2);
if($ku['rubies']>=$money_level)
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$money_level)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_garden` SET `level` = '$petground[next_level]' WHERE `id` = '$petground[id]'");
}
else $_SESSION['no_rubies']=$ku['rubies']-$money_level;
header("Location:/mygarden/moderate/".passgen());
exit;
}
?>