Файл: titwar.ru/trade.php
Строк: 81
<?
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
switch($_GET['action']) {
default:
$title = 'Buy gold';
include './system/h.php';
?>
<div class='line'></div>
<div class='content'>Transaction is temporarily not available.</div>
<?
include './system/f.php';
break;
case 'exchange':
$title = 'Exchanger';
include './system/h.php';
$course = 500;
$g = _string(_num($_GET['g']));
if($g) {
if($_GET['buy'] == true) {
if($user['s'] < $course * $g) {
header('location: /trade/exchange/');
exit;
}
mysql_query('UPDATE `users` SET `g` = "'.($user['g'] + $g).'", `s` = "'.($user['s'] - $course * $g).'" WHERE `id` = "'.$user['id'].'"');
}
else
{
if($user['g'] < $g) {
header('location: /trade/exchange/');
exit;
}
mysql_query('UPDATE `users` SET `g` = "'.($user['g'] - $g).'", `s` = "'.($user['s'] + $course * $g).'" WHERE `id` = "'.$user['id'].'"');
}
header('location: /trade/exchange/');
}
?>
<div class='line'></div>
<div class='content' align='center'>
<img src='/images/town/gold.png' alt='*'/>
</div>
<div class='line'></div>
<div class='list'>
<div class='content' align='center'><font color='#9bc'>Exchange <img src='/images/icon/silver.png' alt='*'/> silver to <img src='/images/icon/gold.png' alt='*'/> gold</font></div>
<div class='line'></div>
<?
for($i = 1; $i <= ($user['level'] > 10 ? 10:$user['level']); $i++) {
if($i == 1 OR $i == 5 OR $i == 10) {
if($user['s'] > $course * $i) {
?>
<li><a href='/trade/exchange/<?=$i?>/?buy=true'><img src='/images/icon/arrow.png' alt='*'/> <img src='/images/icon/silver.png' alt='*'/> <font color='#ffffff'><?=n_f($course * $i)?> → <img src='/images/icon/gold.png' alt='*'/> <?=$i?> </font></a></li>
<?
}
}
}
?>
<li class='no_b'></li>
</div>
<div class='line'></div>
<div class='list'>
<div class='content' align='center'><font color='#9bc'>Buy <img src='/images/icon/silver.png' alt='*'/> silver</font></div>
<div class='line'></div>
<?
for($i = 1; $i <= ($user['level'] > 10 ? 10:$user['level']); $i++) {
if($i == 1 OR $i == 5 OR $i == 10) {
if($user['g'] >= $i) {
?>
<li><a href='/trade/exchange/<?=$i?>/'><img src='/images/icon/arrow.png' alt='*'/> <font color='#ffffff'><img src='/images/icon/gold.png' alt='*'/> <?=$i?> → <img src='/images/icon/silver.png' alt='*'/> <?=n_f($course * $i)?></font></a></li>
<?
}
}
}
?>
<li class='no_b'></li>
</div>
<?
include './system/f.php';
break;
}
?>