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

   $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=1000*$col_rub;
if($ku['money']>=$need_mcr)
{
if($col_rub>=$count1)
{
mysql_query("UPDATE `kolhoz_user` SET `time_obmen` = '$time', `rubies` = '".($ku['rubies']+$col_rub)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
}
else mysql_query("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']))
{
$need_mcr=1000;
if($ku['money']>=$need_mcr)
{
if($col_rub>=$count1)
{
$tkt=$col_rub-1;
$tt=$time_rub*$tkt;
$ttt=$time-$tt;
mysql_query("UPDATE `kolhoz_user` SET `time_obmen` = '$ttt', `rubies` = '".($ku['rubies']+1)."', `money` = '".($ku['money']-$need_mcr)."' WHERE `id` = '$ku[id]'");
}
else mysql_query("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=1;
$mok=2000;
if($ku['rubies']>=$need_mcr)
{
mysql_query("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=10;
$mok=20000;
if($ku['rubies']>=$need_mcr)
{
mysql_query("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='input_button'><center>Обменять на монеты</center></div>
<div class="content">
<div class="block">
<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"> 1 тотем
на <img width="16" height="16" src="images/icons/money.png" alt="o"> 2000 монет.
</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"> 10 тотемов на <img width="16" height="16" src="images/icons/money.png" alt="o"> 20000 монет.
</li>
</ul>
</div></div></div>
<div class='input_button'><center>Обменять на тотемы</center></div>
<div class="content">
<div class="block">
<div>
<img width="16" height="16" src="images/icons/convert.png" alt="o">
<?
if($col_rub>0)echo "<a href='?converter&one'>Обменять</a> <img width='16' height='16' src='images/icons/money.png' alt='o'> 1000 монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> 1 тотем.<br></div><div><img width='16' height='16' src='images/icons/convert.png' alt='o'> <a href='?converter&all'>Обменять</a> <img width='16' height='16' src='images/icons/money.png' alt='o'> <span>".($col_rub*1000)."</span> монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span>$col_rub</span> тотемов.<br/>";
else echo "<span>Обменять</span> <img width='16' height='16' src='images/icons/money.png' alt='o'> 1000 монет на <img width='16' height='16' src='images/icons/ruby.png' alt='o'> 1 рубин.<br>";
echo "</div>
<div class='minor ptm'>Сейчас доступно к обмену:
<span class='title'>$col_rub</span> / <span class='title'>$count1</span>";
?>
 (зависит от количества достижений и <a href='?shop=flowerbed'>Торговца</a>).</div>
</div></div></div>
<div class='input_button'><center>Купить тотемы</center></div>
<div class="content">
<div class="block">
<div>
<img width="16" height="16" src="images/icons/ruby.png" alt="o"> <a href="?payment">Купить</a>
</div>
</div>