<?
require_once '../core/system.php';
$header = 'Обменник';
require_once '../core/head.php';
switch($act) {
case '1':
if($user[silver] > 9999){
mysql_query("UPDATE `user` SET `silver` = '".($user['silver']-10000)."', `gold` = '".($user['gold']+20)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно серебра!';
exit();
}
break;
case '2':
if($user[silver] > 4999){
mysql_query("UPDATE `user` SET `silver` = '".($user['silver']-5000)."', `gold` = '".($user['gold']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно серебра!';
exit();
}
break;
case '3':
if($user[silver] > 499){
mysql_query("UPDATE `user` SET `silver` = '".($user['silver']-500)."', `gold` = '".($user['gold']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно серебра!';
exit();
}
break;
case '4':
if($user[gold] > 0){
mysql_query("UPDATE `user` SET `silver` = '".($user['silver']+500)."', `gold` = '".($user['gold']-1)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно золота!';
exit();
}
break;
case '5':
if($user[gold] > 9){
mysql_query("UPDATE `user` SET `silver` = '".($user['silver']+5000)."', `gold` = '".($user['gold']-10)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно золота!';
exit();
}
break;
case '6':
if($user[gold] > 19){
mysql_query("UPDATE `user` SET `silver` = '".($user['silver']+10000)."', `gold` = '".($user['gold']-20)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно золота!';
exit();
}
break;
default;
echo "<div class='player center'>";
echo "<img src='/images/town/gold.png'>";
echo "</div>";
echo "<div class='dot-line'></div>";
echo "<div class='player center blue'>";
echo "Обмен: <img src='/images/icon/silver.png'> Серебро на <img src='/images/icon/gold.png'> Золото";
echo "</div>";
echo "<div class='mini-line'></div>";
if($user[silver] > 499){
echo "<div class='player menuList'>";
if($user[silver] > 9999)echo "<li><a href='?act=1'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/silver.png'><span class='white'>10000</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>20</span></a></li>";
if($user[silver] > 4999)echo "<li><a href='?act=2'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/silver.png'><span class='white'>5000</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>10</span></a></li>";
if($user[silver] > 499)echo "<li><a href='?act=3'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/silver.png'><span class='white'>500</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>1</span></a></li>";
echo "</div>";
}else{
echo "<div class='player'>У вас не достаточно серебра!</div>";
}
echo "<div class='mini-line'></div>";
echo "<div class='player center blue'>Купить <img src='/images/icon/silver.png'> Серебро</div>";
echo "<div class='dot-line'></div>";
if($user[gold] > 0){
echo "<div class='player menuList'>";
if($user[gold] > 19)echo "<li><a href='?act=6'><img src='/images/icon/arrow.png'>Купить <img src='/images/icon/silver.png'><span class='white'>10000</span> <span class='blue'> за </span><img src='/images/icon/gold.png'><span class='white'>20</span></a></li>";
if($user[gold] > 9)echo "<li><a href='?act=5'><img src='/images/icon/arrow.png'>Купить <img src='/images/icon/silver.png'><span class='white'>5000</span> <span class='blue'> за </span><img src='/images/icon/gold.png'><span class='white'>10</span></a></li>";
if($user[gold] > 0)echo "<li><a href='?act=4'><img src='/images/icon/arrow.png'>Купить <img src='/images/icon/silver.png'><span class='white'>500</span> <span class='blue'> за </span><img src='/images/icon/gold.png'><span class='white'>1</span></a></li>";
echo "</div>";
}else{
echo "<div class='player'>У вас нет золота!</div>";
}
}
require_once '../core/foot.php';
?>