<?
   $count1=6;
$count1=floor($ku['dostig']/5)+$count1;
if(isset($flowerbed_act))$count1=$count1+$flowerbed_act;

//$count1 = floor($count1*50000);

   $time_rub=floor(86400/$count1);
   $time1=$time-$ku['time_obmen'];
   $col_rub=floor($time1/$time_rub);
         if($col_rub>$count1)$col_rub=$count1;

if(isset($_GET['all'])){
$need_mcr=500*$col_rub;
if($ku['money']>=$need_mcr){
if($col_rub>=$count1){
mysql_querll("UPDATE `kolhoz_user` SET `time_obmen` = '$time', `rubies` = '".($ku['rubies']+$col_rub)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
} else mysql_querll("UPDATE `kolhoz_user` SET `time_obmen` = '".($ku['time_obmen']+($col_rub*$time_rub))."', `rubies` = '".($ku['rubies']+$col_rub)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
} else $_SESSION['no_money']=$need_mcr-$ku['money'];
header("Location:?converter");
exit;
}

elseif(isset($_GET['one']) && ($col_rub>=1)){
$need_mcr=1000;
if($ku['money']>=$need_mcr){
if($col_rub>=$count1){
$tkt=$col_rub-1;
$tt=$time_rub*$tkt;
$ttt=$time-$tt;
mysql_querll("UPDATE `kolhoz_user` SET `time_obmen` = '$ttt', `rubies` = '".($ku['rubies']+1)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
} else mysql_querll("UPDATE `kolhoz_user` SET `time_obmen` = '".($ku['time_obmen']+$time_rub)."', `rubies` = '".($ku['rubies']+1)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
} else $_SESSION['no_money']=$need_mcr-$ku['money'];
header("Location:?converter");
exit;
}

elseif(isset($_GET['money_one'])){
$need_mcr=10000000000;
$mok=20000000000000;
if($ku['rubies']>=$need_mcr){
mysql_querll("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$need_mcr)."', `money` = '".($ku['money']+$mok)."' WHERE `id` = '$ku[id]'");
} else $_SESSION['no_rubies']=$need_mcr-$ku['rubies'];
header("Location:?converter");
exit;
}

elseif(isset($_GET['money_all'])){
$need_mcr=1000000000000;
$mok=2000000000000000;
if($ku['rubies']>=$need_mcr){
mysql_querll("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$need_mcr)."', `money` = '".($ku['money']+$mok)."' WHERE `id` = '$ku[id]'");
} else $_SESSION['no_rubies']=$need_mcr-$ku['rubies'];
header("Location:?converter");
exit;
}

elseif(isset($_GET['money_all2'])){
$need_mcr=100000000000000;
$mok=200000000000000000;
if($ku['rubies']>=$need_mcr){
mysql_querll("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$need_mcr)."', `money` = '".($ku['money']+$mok)."' WHERE `id` = '$ku[id]'");
} else $_SESSION['no_rubies']=$need_mcr-$ku['rubies'];
header("Location:?converter");
exit;
}
?>
<div class="event"><h1>Обменный пункт</h1></div>
<div class="content">
<div class="block">
<h3>Обменять на монеты</h3>
<ul>
<li>
<img width="16" height="16" src="images/icons/convert.png" alt="o"> <a href="?converter&money_one">Обменять</a> <img width="16" height="16" src="images/icons/ruby.png" alt="o"> 10000000000 рубинов
на <img width="16" height="16" src="images/icons/money.png" alt="o"> 20000000000000 монет.
</li>
<li>
<img width="16" height="16" src="images/icons/convert.png" alt="o"> <a href="?converter&money_all">Обменять</a> <img width="16" height="16" src="images/icons/ruby.png" alt="o"> 1000000000000 рубинов на <img width="16" height="16" src="images/icons/money.png" alt="o"> 2000000000000000 монет.
</li>
<li>
<img width="16" height="16" src="images/icons/convert.png" alt="o"> <a href="?converter&money_all2">Обменять</a> <img width="16" height="16" src="images/icons/ruby.png" alt="o"> 100000000000000 рубинов на <img width="16" height="16" src="images/icons/money.png" alt="o"> 200000000000000000 монет.
</li>
</ul>

<img width="16" height="16" src="images/icons/ruby.png" alt="o"> <a href="?payment">Купить</a>
</div>
</div>
<?
include_once 'inc/foot.php'; 
?>