<?
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
$set['title']='FM Банк';
include_once '../sys/inc/thead.php';
title();
err();
aut();
if (!isset($user)){header("Location: index.php?".SID);exit;}
include_once 'online.php';
if (isset($_GET['exchange']) && $_GET['exchange']==1 && isset($_POST['fuli']))
{
$fuli=intval($_POST['fuli']);
if (!$fuli || $fuli<1)$err="Введите Баллов!";
if ($user['balls']<$fuli)$err="У вас нет $fuli Баллов!";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `fm_club` WHERE `id_user` = '$user[id]'"),0)==0)$err='Jer Sheidzinet klubi!';
if (!isset($err))
{
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']-$fuli)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `fm_money` = '".($user['fm_money']+$fuli)."' WHERE `id` = '$user[id]' LIMIT 1");
msg("Вы обменили $fuli Баллов!");
}
}

if (isset($_GET['exchange']) && $_GET['exchange']==2 && isset($_POST['fuli']))
{
$fuli=intval($_POST['fuli']);
if (!$fuli || $fuli<1)$err="Введите Долларов!";
if ($user['fm_money']<$fuli)$err="У вас нет $fuli Долларов!";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `fm_club` WHERE `id_user` = '$user[id]'"),0)==0)$err='Jer Sheidzinet klubi!';
if (!isset($err))
{
mysql_query("UPDATE `user` SET `fm_money` = '".($user['fm_money']-$fuli)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+$fuli)."' WHERE `id` = '$user[id]' LIMIT 1");
msg("Вы обменяли $fuli Долларов!");
}
}


err();

$user=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$user[id]' LIMIT 1"));
echo '<div class="frends2">';
echo 'Баллы: <b>'.$user['balls'].'</b><br/>';
echo 'Бюжет: <b>'.$user['fm_money'].'$</b><br/>';
echo '<form action="bank.php?exchange=1" method="post"><div>';
echo '<input name="fuli" type="text" size="8" value=""/>';
echo '<input type="submit" class="doctor" value="Баллы &#187; Доллары"/>';
echo '</div></form>';
echo '<form action="bank.php?exchange=2" method="post"><div>';
echo '<input name="fuli" type="text" size="8" value=""/>';
echo '<input type="submit" class="doctor" value="Доллары &#187; Баллы"/>';
echo '</div></form>';
echo '</div>';

echo "<div class='foot'>";
echo "&#171; <a href='index.php'>Назад</a><br/>";
echo "</div>";

include_once '../../sys/inc/tfoot.php';

?>
