<?php

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']='Villa'; // заголовок страницы

include_once '../sys/inc/thead.php';
title();
err();
aut();

$gconf=mysql_fetch_array(mysql_query("SELECT * FROM `game_zone`"));

if(isset($user)){
if($gconf[0]['open']!=1){


echo '<b><font color="red">Bank</font></b><br/>';


$action=htmlspecialchars(trim($_GET['action']));


switch ($action){

default:
echo 'Hi, '.$user['nick'].'!<br/>';
echo 'Do you have a <b>'.$user['balls'].'</b> Site credits!<br/>';
echo 'Money: <b>'.$user['gorod_money'].'</b><br/>';
echo 'Swap them for coins at the rate of 1 point = 100 coins<br/>';
echo '<form action="bank.php?action=change" method="post">';
echo 'How many points do you want to change:<br/>';
echo '<input name="num" type="text" value=""/><br/>';
echo '<input type="submit" value="Submit"/>';
echo '</form>';
break;


case 'change':
$num=(int)$_POST['num'];
if(!$num || $num<1){echo 'Empty options!';break;};
if($user['balls']<$num){echo 'You do not have enough points!';break;};
$baks=$num*100;
mysql_query("UPDATE `user` SET `gorod_money`=`gorod_money`+'$baks',`balls`=`balls`-'$num' WHERE `id`='".$user['id']."'");
echo 'You have successfully redeem money! <a href="bank.php">Back to the bank</a><br/>';
break;


};
echo '<div class="msg"><a href="index.php">Home Page</a></div>';
}else{echo '<div class="msg">The game is locked by the administrator!</div>';};

}else{
echo '<div class="msg">The game is only available for Authorizing Users!</div>';
};
include_once "kto.php";
include_once '../sys/inc/tfoot.php';
?>