<?
    
    include './system/common.php';
    
 include './system/functions.php';
        
      include './system/user.php';
    
if(!$user) {

  header('location: /');
    
exit;

}

switch($_GET['action']) {

  default:

    $title = 'Покупка золотых';    

include './system/h.php';

?>

<div class='title'><?=$title?></div>
 <div class='line'></div>
<div class='content' align='center'>
  <font color='#9bc'>Золото самый ценный ресурс!</font>
</div>
<div class='line'></div>
<div class='list'>
<div class='content' align='center'>Купить золото</div>
</div>
<div class='line'></div>
<div class='menu'>

  <li><table cellpadding='0' cellspacing='0'><tr>
  <td valign='top'><img src='/images/gold/0.png' alt='*'/></td>
  <td valign='top' style='padding-left: 5px;'><b>Горсть золота</b><br/>
  <img src='/images/icon/gold.png' alt='*'/> <b>9000</b><br/>
  <font color='#9c9'>+1000</font> в подарок</td></tr></table><br/>
  <a href='/worldkassa/index.php?gold=10000' class='button'>Купить за 5 руб.</a>
  </li>

  <li><table cellpadding='0' cellspacing='0'><tr>
  <td valign='top'><img src='/images/gold/-1.png' alt='*'/></td>
  <td valign='top' style='padding-left: 5px;'><b>Мешок золота</b><br/>
  <img src='/images/icon/gold.png' alt='*'/> <b>40000</b><br/>
  <font color='#9c9'>+10000</font> в подарок</td>
  </tr></table><br/>
  <a href='/worldkassa/index.php?gold=50000' class='button'>Купить за 50 руб.</a></li>

  <li><table cellpadding='0' cellspacing='0'><tr>
  <td valign='top'><img src='/images/gold/-2.png' alt='*'/></td>
  <td valign='top' style='padding-left: 5px;'><b>Ларец золота</b><br/>
  <img src='/images/icon/gold.png' alt='*'/> <b>90000</b><br/>
  <font color='#9c9'>+1000</font> в подарок</td>
  </tr></table><br/>
  <a href='/worldkassa/index.php?gold=100000' class='button'>Купить за 100 руб.</a></li>

  <li><table cellpadding='0' cellspacing='0'><tr>
  <td valign='top'><img src='/images/gold/-3.png' alt='*'/></td>
  <td valign='top' style='padding-left: 5px;'><b>Сундук золота</b><br/>
  <img src='/images/icon/gold.png' alt='*'/> <b>400000</b><br/>
  <font color='#9c9'>+100000</font> в подарок</td>
  </tr></table><br/>
  <a href='/worldkassa/index.php?gold=500000' class='button'>Купить за 200 руб.</a></li>

  <li><table cellpadding='0' cellspacing='0'><tr>
  <td valign='top'><img src='/images/gold/-4.png' alt='*'/></td>
  <td valign='top' style='padding-left: 5px;'><b>Сокровище богов</b><br/>
  <img src='/images/icon/gold.png' alt='*'/> <b>1200000</b><br/>
  <font color='#9c9'>+5000</font> в подарок</td>
  </tr></table><br/>
  <a href='/worldkassa/index.php?gold=1250000' class='button'>Купить за 300 руб.</a></li>

 <li class='no_b'></li>
</div>

<?
  
include './system/f.php';

          break;

case 'exchange':

    $title = 'Обменник';    

include './system/h.php';

  $course = 50;

$gz = _string(_num($_GET['g']));
  if($g) {
  
  if($_GET['buy'] == true) {

    if($user['duel_rating'] < $course * $g) {
    
        header('location: /reyting/exchange/');
    
    exit;
    
    }
  
  mysql_query('UPDATE `users` SET `g` = "'.($user['g'] + $g).'", `duel_rating` = "'.($user['duel_rating'] - $course * $g).'" WHERE `id` = "'.$user['id'].'"');
    
  }
  else
  {

    if($user['g'] < $g) {
    
        header('location: /reyting/exchange/');
    
    exit;
    
    }
    
  mysql_query('UPDATE `users` SET `g` = "'.($user['g'] - $g).'", `duel_rating` = "'.($user['duel_rating'] + $course * $g).'" WHERE `id` = "'.$user['id'].'"');
  
  }
  
        header('location: /reyting/exchange/');
  
  }

?>

<div class='title'><?=$title?></div>
 <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'>Обмен <img src='/images/icon/sumstat.png' alt='*'/> Рейтинга дуэлей на <img src='/images/icon/gold.png' alt='*'/> золото</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['duel_rating'] > $course * $i) {

?>

<li><a href='/reyting/exchange/<?=$i?>/?buy=true'><img src='/images/icon/arrow.png' alt='*'/> <img src='/images/icon/sumstat.png' alt='*'/> <font color='#ffffff'><?=n_f($course * $i)?> на  <img src='/images/icon/gold.png' alt='*'/> <?=$i?>            </font></a></li>

<?

  }
  
  }
  
  }

?>




</div>



<div class='list'>


<?

  for($i = 1; $i <= ($user['level'] > 10 ? 10:$user['level']); $i++) {

  if($i == 1 OR $i == 5 OR $i == 10) {

  if($user['g'] >= $i) {

?>



<?

  }

  }
  
  }

?>




</div>



<?

include './system/f.php';

break;

}

?>