<?
session_start();
ob_start();
include_once "inc/db_connect.php";
include_once "inc/fnc.php";
include 'head.php';
header('Content-Type: text/html;charset=utf8');
$err = "";
if(isset($_POST['regok'])){unset($_SESSION['reg_ok']);}
if(!isset($_SESSION['user'])){
	header("Location: index.php?");
	exit();
}
if(isset($_POST['ok']) && $_POST['mdp']==$ku['mdp'] && intval($_POST['sum'])>0)
{
$summ=intval($_POST['sum']);
$sum=(($summ/100)*10)+$summ;
if($ku['money']>=$sum)
{
$ku['money']=minus_money($sum);
mysql_query("UPDATE `users` SET `money` = '".($ank['money']+$summ)."' WHERE `id` = '$ank[id]'");
mysql_query("INSERT INTO `mail` SET `id_user` = '$ank[id]', `id_kont` = '0', `msg` = '".("$ku[nick] прислал".($ku['pol']==0?'a':null)." вам $summ мон.")."', `time` = '$time', `type` = 'to'");
mysql_query("INSERT INTO `mail` SET `id_user` = '$ku[id]', `id_kont` = '0', `msg` = '".("Вы переслали $summ мон. фермеру $ank[nick]")."', `time` = '$time', `type` = 'at', `read` = '1'");
msg_game("Передача успешно завершена");
}
else no_money($summ-$ku['money']);
}
echo "<div class='title'><b>Передача монет</b></div>";
echo "<div class='mono'>";
echo "Введите количество монет:</span><br/><form method='post'>";
echo "<input type='text' name='sum' value=''><input type='hidden' name='mdp' value='$ku[mdp]'><br/>";
echo "<input type='submit' name='ok' value='Передать'>";
echo "</form></div>";
include_once 'foot.php';
?>