<?
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';
require 'config.php';
if(isset($_GET['act'])){$act = power($_GET['act']);}else{$act='index';}
only_reg();
switch ($act):
case "index":
$set['title']='Vip статус';
include_once '../sys/inc/thead.php';
title();
echo '♥ Цена vip-статуса: '.$cena.' баллов<br/>';
echo '♥ Продолжительность: 10 дней<br/>';
echo '♥ Доступны новые иконки возле ника<br/>';
if($user['balls']>$cena && mysql_result(mysql_query("SELECT COUNT(*) FROM `vipstat` WHERE `user` = '$user[id]'"),0)==0){
echo '<form method="post" action="index.php?act=buy">';
echo '<input type="submit" value="Купить статус"/>';
echo'</form>';
}else{
if($user['balls']<$cena){echo'<span style="color:#ff0000">♥ В данный момент у вас недостаточно баллов</span><br/>';}
echo'<span style="color:#ff0000">♥ У вас уже есть vip-статус</span>';}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `vipstat` WHERE `user` = '$user[id]'"),0)==1){
echo '<form method="post" action="index.php?act=sell">';
echo '<input type="submit" value="Продать vip"/>';
echo'</form>';
}
break;
case "sell":
$set['title']='Продажа vip-статуса';
include_once '../sys/inc/thead.php';
title();
$vozr = $cena/2;
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `vipstat` WHERE `user` = '$user[id]'"),0)==0){header("Location: index.php");}
if(isset($_GET['ok'])){
mysql_query("UPDATE `user` SET `balls` = `balls`+$vozr WHERE `id` = '$user[id]'"); 
mysql_query("DELETE FROM `vipstat` WHERE `user` = '$user[id]'");
header("Location: /info.php?id=$user[id]");
}
echo'Сумма получаемая вами после продажи статуса <b>'.$vozr.'</b> баллов<br/>';
echo '<form method="post" action="index.php?act=sell&ok">';
echo '<input type="submit" value="Продать"/>';
echo'</form>';
break;
case "buy":
$set['title']='Выбор иконки Vip статуса';
include_once '../sys/inc/thead.php';
title();
if($user['balls']<$cena || mysql_result(mysql_query("SELECT COUNT(*) FROM `vipstat` WHERE `user` = '$user[id]'"),0)==1){header("Location: index.php");}
if(isset($_GET['ok'])){
$icon = intval($_POST['icon']);
mysql_query("UPDATE `user` SET `balls` = `balls`-$cena WHERE `id` = '$user[id]'"); 
mysql_query("INSERT INTO `vipstat` (`user`, `icon`, `time`) values('$user[id]', '$icon', '$time')");
header("Location: /info.php?id=$user[id]");
}
?>
<div class='fyt'>
Выбираем иконку которая будет возле вашего ника
</div>
<?
echo '<form method="post" action="index.php?act=buy&ok">';
echo '<input type="radio" name="icon" value="4" checked/> <img src="icon/4.png" alt="4"/><br/>';
echo '<input type="radio" name="icon" value="5"/> <img src="icon/5.png" alt="5"/><br/>';
echo '<input type="radio" name="icon" value="6"/> <img src="icon/6.png" alt="6"/><br/>';
echo '<input type="radio" name="icon" value="1"/> <img src="icon/1.png" alt="1"/><br/>';
echo '<input type="radio" name="icon" value="2"/> <img src="icon/2.png" alt="2"/><br/>';
echo '<input type="radio" name="icon" value="3"/> <img src="icon/3.png" alt="3"/><br/>';
echo '<input type="submit" value="Купить"/>';
echo'</form>';
break;
default:
header("location: index.php?");
endswitch;
include_once '../sys/inc/tfoot.php';
?>