<?  
include './system/common.php';  
include './system/functions.php';
include './system/user.php';

if(!$user) {
header('location: /');
exit;}

$title = 'Магазин';    
include './system/h.php';  

$buy_complect = _string(_num($_GET['buy_complect']));

    if($buy_complect) {

   if(mysql_result(mysql_query('SELECT COUNT(*) FROM `inv` WHERE `user` = "'.$user['id'].'" AND `equip` = "0"'),0) + 8 > 20) {
$_SESSION['mes'] = mes('Ваша сумка переполнена!');
header('Location:/shop/complect/'.$buy_complect.'/');
exit;}
    
    $complect = mysql_query('SELECT * FROM `complects` WHERE `id` = "'.$buy_complect.'"');
    $complect = mysql_fetch_array($complect);
    
    switch($complect['quality']) { //Уровни по которым доступны вещи в магазине
case 1:
$complect_quality_skill =   1;
break;
case 2:
$complect_quality_skill =  7;
break;
case 3:
$complect_quality_skill =  12;
break;
case 4:
$complect_quality_skill =  24;
break;
case 5:
$complect_quality_skill =  36;
break;
case 6:
$complect_quality_skill = 48;
break;
}
    
    if(!$complect OR $complect_quality_skill > $user['level']) {
$_SESSION['mes'] = mes('Маленький уровень');
header('Location:/shop/complect/'.$complect['quality'].'/');
exit;}
    
$cost = 0;
    
    for($w = 1; $w < 9; $w++) {
$shop = mysql_query('SELECT * FROM `shop` WHERE `id` = "'.$complect['w_'.$w].'"');
$shop = mysql_fetch_array($shop);
$cost +=$shop['cost'];
}
$discount=0;//Процент скидки
    $cost -= round(($cost / 100) * $discount);
    
    if($user['g'] < $cost) {
$_SESSION['mes'] = mes('Нехватает <img src=\'/images/ico/png/gold.png\' alt=\'*\'/> '.($cost - $user['g']).' золота!');		
header('Location:/shop/complect/'.$complect['quality'].'/');
exit;}

mysql_query('UPDATE `users` SET `g` = "'.($user['g'] - $cost).'" WHERE `id` = "'.$user['id'].'"');
for($w = 1; $w < 9; $w++) {
    
	
$task_id=19;// Купи 3 любые вещи в магазине
$req = mysql_query('select * from `task_user` WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'") AND (`complete`="0")');
    if (mysql_num_rows ($req) != 0) {
while ($t = mysql_fetch_array ($req)) {
$task = mysql_fetch_array(mysql_query ('SELECT * FROM `task` WHERE (`id`="'.$task_id.'")'));
if ($t['how'] < $task['how']){                            
mysql_query ('UPDATE `task_user` SET `how`=3 WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'")');
}}}
/////////////////////////
	
	
	
	
      $shop = mysql_query('SELECT * FROM `shop` WHERE `id` = "'.$complect['w_'.$w].'"');
      $shop = mysql_fetch_array($shop);
    
mysql_query('INSERT INTO `inv` (`user`,
                                `item`,
								`quality`,
                                 `_str`,
                                 `_vit`,
                                 `_def`) VALUES ("'.$user['id'].'",
                                                 "'.$shop['id'].'",
                                                 "'.$shop['quality'].'",                                                 
                                                 "'.$shop['_str'].'",
                                                 "'.$shop['_vit'].'",
                                                 "'.$shop['_def'].'")');
    
    }
$_SESSION['mes'] = mes('Комплект успешно куплен!');
header('location: /inv/');
exit;
}






$buy_item = _string(_num($_GET['buy_item']));
if($buy_item) {
$itemshop = mysql_fetch_array(mysql_query('SELECT * FROM `shop` WHERE `id` = \''.$buy_item.'\''));
  
  $cost=$itemshop['cost'];
  $discount=0;//Процент скидки
    $cost -= round(($cost / 100) * $discount);
    
    
  if(mysql_result(mysql_query('SELECT COUNT(*) FROM `inv` WHERE `user` = \''.$user['id'].'\' AND `equip` = \'0\''),0) + 1 > 20){
header('Location:/shop/complect/'.$itemshop['quality'].'/');
$_SESSION['mes'] = mes('Ваша сумка переполнена!');
exit; } 
  if($itemshop['cost'] > $user['g']){
header('Location:/shop/complect/'.$itemshop['quality'].'/');
$_SESSION['mes'] = mes('Нехватает <img src=\'/images/ico/png/gold.png\' alt=\'*\'/> '.($cost - $user['g']).' золота!');
exit; }


$task_id=19;// Купи 3 любые вещи в магазине
$req = mysql_query('select * from `task_user` WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'") AND (`complete`="0")');
    if (mysql_num_rows ($req) != 0) {
while ($t = mysql_fetch_array ($req)) {
$task = mysql_fetch_array(mysql_query ('SELECT * FROM `task` WHERE (`id`="'.$task_id.'")'));
if ($t['how'] < $task['how']){                           
mysql_query ('UPDATE `task_user` SET `how`=`how`+1 WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'")');
}else{
mysql_query ('UPDATE `task_user` SET `how`=3 WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'")');
}}}
/////////////////////////

    mysql_query('UPDATE `users` SET `g` = `g` - '.$cost.' WHERE `id` = \''.$user['id'].'\'');
	mysql_query('INSERT INTO `inv` (`user`,
                                    `item`,
								    `quality`,
                                    `_str`,
                                    `_vit`,
                                    `_def`) VALUES ("'.$user['id'].'",
                                                 "'.$itemshop['id'].'",
                                                 "'.$itemshop['quality'].'",                                                 
                                                 "'.$itemshop['_str'].'",
                                                 "'.$itemshop['_vit'].'",
                                                 "'.$itemshop['_def'].'")');
header('location: /inv/');
$_SESSION['mes'] = mes('Вещь успешно куплена!');
exit; 
}


switch($_GET['action']) {
default:

$title = 'Рынок';
require_once ('system/h.php');
echo '<div class="title">'.$title.'</div>';

 echo' '.$_SESSION['mes'].' ';
    $_SESSION['mes']=NULL; //Удаляем сесию

$i=1;
while($i<=6){switch($i){
case '1':
$link='/shop/items';
$img='cloth';
$title='Снаряжение';
$msg='лучшее оружие и доспехи';
break;
case '2':
$link='/shop/amulet';
$img='amulet';
$title='Амулеты';
$msg='для арены и подземелий';
break;
case '3':
$link='runes/';
$img='runes';
$title='Торговец рунами';
$msg='установка рун на вещи';
break;
case '4':
$link='smith/';
$img='blacksmith';
$title='Кузнец';
$msg='заточка вещей';
break;
case '5':
$link='/ability/'.$user['id'].'/';
$img='ability';
$title='Умения';
$msg='боевые умения';
break;
case '6':
$link='/shop/premium';
$img='premium';
$title='Премиум-аккаунт';
$msg='бонусы';
break;}


echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<a href="'.$link.'"> <img src="/images/ico/shop/'.$img.'.png"> </a>
</td><td> 
<a href="'.$link.'"> '.$title.' </font> </a> 
<br/> '.$msg.' ';
echo' </td></tr>
</tbody></table>
</div> ';
echo'<div class="line"></div>';
$i++;
}
break;


case 'items':

echo '<div class="title">'.$title.'</div>';
$quality = _string(_num($_GET['quality']));
if($quality) {

  if($quality == 1 && $user['level'] < 1 OR 
  $quality == 2 && $user['level'] < 7 OR 
  $quality == 3 && $user['level'] < 12 OR 
  $quality == 4 && $user['level'] < 24 OR 
  $quality == 5 && $user['level'] < 36 OR 
  $quality == 6 && $user['level']  < 48 ) {
    
header('location: /shop/items');
exit;   
}

  $q = mysql_query('SELECT * FROM `complects` WHERE `quality` = \''.$quality.'\'');    
  while($row = mysql_fetch_array($q)) {

    echo '<div class="block_link">
  <a href="/shop/complect/'.$row['id'].'/">
  <img src="/images/ico/quality/'.$row['quality'].'.png" alt="*"/> '.$row['name'].'</a></div>

<div class="line"></div>';
      
  }

echo '<div class="block_link"><a href="/shop/items"><img src="/images/ico/png/back.png" alt="*"/> Назад к снаряжению</a></div>
<div class="line"></div>';

}else{
echo' '.$_SESSION['mes'].'  ';
$_SESSION['mes']=NULL; //Удаляем сесию
   
echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<img src="/images/ico/quality/big_6.png">
</td><td> 
'.($user['level'] >= 48 ? '<a href="/shop/items/6/">':'').'  Мифические вещи '.($user['level'] >= 48 ? '</a>':'').'
<br/> '.($user['level'] >= 48 ? 'Мифические доспехи и оружие':'Требуется 48 уровень').' 
</td></tr>
</tbody></table>
</div><div class="line"></div>';

  
echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<img src="/images/ico/quality/big_5.png">
</td><td> 
'.($user['level'] >= 36 ? '<a href="/shop/items/5/">':'').'  Легендарные вещи '.($user['level'] >= 36 ? '</a>':'').'
<br/> '.($user['level'] >= 36 ? 'Легендарные доспехи и оружие':'Требуется 36 уровень').' 
</td></tr>
</tbody></table>
</div> <div class="line"></div>';


echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<img src="/images/ico/quality/big_4.png">
</td><td> 
'.($user['level'] >= 24 ? '<a href="/shop/items/4/">':'').'  Эпические вещи '.($user['level'] >= 24 ? '</a>':'').'
<br/> '.($user['level'] >= 24 ? 'Эпические доспехи и оружие':'Требуется 24 уровень').' 
</td></tr>
</tbody></table>
</div><div class="line"></div>';
  

echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<img src="/images/ico/quality/big_3.png">
</td><td> 
'.($user['level'] >= 12 ? '<a href="/shop/items/3/">':'').'  Редкие вещи '.($user['level'] >= 12 ? '</a>':'').'
<br/> '.($user['level'] >= 12 ? 'Редкие доспехи и оружие':'Требуется 12 уровень').' 
</td></tr>
</tbody></table>
</div><div class="line"></div>';
  

echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<img src="/images/ico/quality/big_2.png">
</td><td> 
'.($user['level'] >= 7 ? '<a href="/shop/items/2/">':'').'  Необычные вещи '.($user['level'] >= 7 ? '</a>':'').'
<br/> '.($user['level'] >= 7 ? 'Необычные доспехи и оружие':'Требуется 7 уровень').' 
</td></tr>
</tbody></table>
</div><div class="line"></div>';
  

echo'  <div class="empty_block">
<table><tbody><tr>
<td width="15%"> 
<img src="/images/ico/quality/big_1.png">
</td><td> 
'.($user['level'] >= 1 ? '<a href="/shop/items/1/">':'').'  Обычные вещи '.($user['level'] >= 1 ? '</a>':'').'
<br/> '.($user['level'] >= 1 ? 'Обычные доспехи и оружие':'Требуется 1 уровень').' 
</td></tr>
</tbody></table>
</div><div class="line"></div>';

echo'<div class="block_link"><a href="/shop/"><img src="/images/ico/png/back.png" alt="*"/> Назад к категориям </a></div>
<div class="line"></div>';   
}
break;




case 'complect':
$id = _string(_num($_GET['id']));
$complect = mysql_fetch_array(mysql_query('SELECT * FROM `complects` WHERE `id` = \''.$id.'\''));
 
  if(!$complect) {
header('location: /');
exit;}
    
$title = $complect['name'];
echo '<div class="title">'.$title.'</div>';
$cost = 0;

echo' '.$_SESSION['mes'].' ';
    $_SESSION['mes']=NULL; //Удаляем сесию
    
    
for($w = 1; $w < 9; $w++) {
$itemshop = mysql_fetch_array(mysql_query('SELECT * FROM `shop` WHERE `id` = \''.$complect['w_'.$w].'\''));
$cost += $itemshop['cost'];
}
  $discount=0;//Процент скидки
    $cost -= round(($cost / 100) * $discount);
    
echo '<div class="block_link"><a href="/shop/?buy_complect='.$complect['id'].'"> Купить весь комплект за <img src="/images/ico/png/gold.png" alt="*"/> '.$cost.' золота</a>
</div><div class="line"></div>';

for($w = 1; $w < 9; $w++) {

  echo '<div class="empty_block">
  <table cellpadding="0" cellspacing="0"><tr>';

  $itemshop = mysql_fetch_array(mysql_query('SELECT * FROM `shop`  WHERE `id` = \''.$complect['w_'.$w].'\''));
  $item = mysql_fetch_array(mysql_query('SELECT * FROM `items` WHERE `id` = \''.$complect['w_'.$w].'\''));

  
  switch($itemshop['quality']) {
case 1:
$itemquality = 'Обычный';
$quality_col = '#999999';
break;
case 2:
$itemquality = 'Необычный';
$quality_col = '#B1D689';
break;
case 3:
$itemquality = 'Редкий';
$quality_col = '#6BA0E7';
break;
case 4:
$itemquality = 'Эпический';
$quality_col = '#C780DB';
break;
case 5:
$itemquality = 'Легендарный';
$quality_col = '#FF8E94';
break;
case 6:
$itemquality = 'Мифический';
$quality_col = '#FE7E01';
break;
}
  
  
 

  echo '<td width="15%"><img src="/images/items/'.$itemshop['id'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$itemshop['quality'].'.png" alt="*"/> <a href="/shop/item/'.$itemshop['id'].'/">'.$item['name'].'</a><br/>
  <small><font color="#'.(($user['level'] < $item['level']) ? 'c06060':'ffffff').'"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур, </font>
  <font color="'.$quality_col.'"> '.$itemquality.'</font> ';

  if($user['w_'.$item['w']]) {
$equipitem = mysql_fetch_array(mysql_query('SELECT * FROM `inv` WHERE `id` = \''.$user['w_'.$item['w']].'\''));      
    
  if( ($itemshop['_str'] + $itemshop['_vit'] + $itemshop['_def']) - ($equipitem['_str'] + $equipitem['_vit'] + $equipitem['_def']) > 0) echo '<font color=\'#30c030\'>+'.(($itemshop['_str'] + $itemshop['_vit'] + $itemshop['_def']) - ($equipitem['_str'] + $equipitem['_vit'] + $equipitem['_def'])).'</font>';  
}else{  
echo '<font color=\'#30c030\'>+'.($itemshop['_str'] + $itemshop['_vit'] + $itemshop['_def']).'</font>';
}
  
  echo '</small></td>
  </tr></table>
  <div class="link_center"><a href="/shop/?buy_item='.$itemshop['id'].'">Купить <img src="/images/ico/png/gold.png" alt="*" width="16"/> '.$itemshop['cost'].' </a></div>
</div>
<div class=\'line\'></div>';
}

echo '<div class="block_link"><a href="/shop/items/'.$complect['quality'].'/"><img src="/images/ico/png/back.png" alt="*"/> Назад к комплектам </a></div>  <div class="line"></div>';
break;



case 'item':
$id = _string(_num($_GET['id']));
 
$shop = mysql_query('SELECT * FROM `shop` WHERE `id` = "'.$id.'"');
$shop = mysql_fetch_array($shop);
 
  if(!$shop) {
header('location: /');
exit;}
 
  $item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$shop['id'].'"');
  $item = mysql_fetch_array($item);
    
$title = $item['name'];

switch($item['quality']) {
case 1:
$quality = 'Обычный';
$quality_color = '#999999';
break;
case 2:
$quality = 'Необычный';
$quality_color = '#B1D689';
break;
case 3:
$quality = 'Редкий';
$quality_color = '#6BA0E7';
break;
case 4:
$quality = 'Эпический';
$quality_color = '#C780DB';
break;
case 5:
$quality = 'Легендарный';
$quality_color = '#FF8E94';
break;
case 6:
$quality = 'Мифический';
$quality_color = '#FE7E01';
break;
}

    switch($item['w']) {
case 1:
$w = 'Голова';
break;
case 2:
$w = 'Плечи';
break;
case 3:
$w = 'Торс';
break;
case 4:
$w = 'Перчатки';
break;
case 5:
$w = 'Левая рука';
break;
case 6:
$w = 'Правая рука';
break;
case 7:
$w = 'Ноги';
break;
case 8:
$w = 'Обувь';
break;
}



echo'<div class="title">'.$title.'</div>';
echo'<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>
  <td width="15%"><img src="/images/items/'.$item['id'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$item['quality'].'.png" alt="*"/> <font color="#fff"> '.$item['name'].' </font>
  <br/><small><font color="#'.(($user['level'] < $item['level']) ? 'c06060':'ffffff').'"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур, </font>
  <font color="'.$quality_color.'"> '.$quality.'</font>, '.$w.'<br/> 
</small></td>
</tr></table>
</div>
  <div class="line"></div>
<div class="empty_block">
<font color="#90b0c0">';


    $equip_item = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
    $equip_item = mysql_fetch_array($equip_item);

    $diff = 0;



echo'<img src="/images/ico/png/attack.png" alt="*"/> Сила: <font color="';
  
if($shop['_str'] > $equip_item['_str']) {
$diff += $shop['_str'] - $equip_item['_str'];
echo'#3c3';
}else{
echo'#c66';
}
echo'"> '.$shop['_str'].'</font><br/>';


echo'<img src="/images/ico/png/hp.png" alt="*"/> Жизнь: <font color="';
if($shop['_vit'] > $equip_item['_vit']) {
$diff += $shop['_vit'] - $equip_item['_vit'];
echo'#3c3'; 
}else{
echo'#c66';
}
echo'"> '.$shop['_vit'].'</font><br/>';


echo'<img src="/images/ico/png/def.png" alt="*"/> Защита: <font color="';
if($shop['_def'] > $equip_item['_def']) {
$diff += $shop['_def'] - $equip_item['_def'];
echo'#3c3'; 
}else{
echo'#c66';
}
echo'"> '.$shop['_def'].' </font><br/>';

  
  
  if($user['w_'.$item['w']] != 0) {
    if($shop['_str'] > $equip_item['_str'] OR $shop['_vit'] > $equip_item['_vit'] OR $shop['_def'] > $equip_item['_def']) {
echo' <font color="#3c3">Лучше +'.$diff.'</font>';
    }
}
  


echo' </font>
<div class="link_center"><a href="/shop/?buy_item='.$shop['id'].'/"> Купить  <img src="/images/ico/png/gold.png" alt="*" width="16"/> '.$shop['cost'].' </a></div>
</div><div class="line"></div>';


  if($equip_item) {

    $i_equip_item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$equip_item['item'].'"');
    $i_equip_item = mysql_fetch_array($i_equip_item);

switch($i_equip_item['quality']) {
case 1:
$quality = 'Обычный';
$quality_color = '#999999';
break;
case 2:
$quality = 'Необычный';
$quality_color = '#B1D689';
break;
case 3:
$quality = 'Редкий';
$quality_color = '#6BA0E7';
break;
case 4:
$quality = 'Эпический';
$quality_color = '#C780DB';
break;
case 5:
$quality = 'Легендарный';
$quality_color = '#FF8E94';
break;
case 6:
$quality = 'Мифический';
$quality_color = '#FE7E01';
break;
}

    switch($i_equip_item['w']) {
case 1:
$w = 'Голова';
break;
case 2:
$w = 'Плечи';
break;
case 3:
$w = 'Торс';
break;
case 4:
$w = 'Перчатки';
break;
case 5:
$w = 'Левая рука';
break;
case 6:
$w = 'Правая рука';
break;
case 7:
$w = 'Ноги';
break;
case 8:
$w = 'Обувь';
break;
}



  

echo'<div class="title"><small> На вас одето </small></div>';
echo'<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>
  <td width="15%"><img src="/images/items/'.$equip_item['item'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$i_equip_item['quality'].'.png" alt="*"/>  <font color="#fff"> '.$i_equip_item['name'].' </font>
  <br/>
  <small><font color="#'.(($user['level'] < $item['level']) ? 'c06060':'ffffff').'"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур, </font>
  <font color="'.$quality_color.'"> '.$quality.'</font>, '.$w.'<br/>
  </small></td>
</tr></table>
  
  </div><div class="line"></div>
  <div class="empty_block">
  <font color="#90b0c0">
  <img src="/images/ico/png/attack.png" alt="*"/> Сила:  '.$equip_item['_str'].' <br/>
  <img src="/images/ico/png/hp.png" alt="*"/> Жизнь: '.$equip_item['_vit'].' <br/>
  <img src="/images/ico/png/def.png" alt="*"/> Защита:'.$equip_item['_def'].' <br/>
  </font>
  </div><div class="line"></div>';


  
  }
  $complect = mysql_fetch_array(mysql_query('SELECT * FROM `complects` WHERE `w_1` = "'.$item['id'].'" '));
  echo '<div class="block_link"><a href="/shop/complect/'.$complect['id'].'/"><img src="/images/ico/png/back.png" alt="*"/> Назад к комплекту </a></div>  <div class="line"></div>';

break;


	   
case 'amulet':
$title = 'Амулеты';

    $amulet = mysql_query('SELECT * FROM `amulet` WHERE `id` = "'.$user['amulet'].'"');
    $amulet = mysql_fetch_array($amulet);
    $amulet_new = mysql_query('SELECT * FROM `amulet` WHERE `id` = "'.($user['amulet']+1).'"');
    $amulet_new = mysql_fetch_array($amulet_new);


if($_GET['buy'] == true) {
  if($user['amulet'] >= '55'){
$_SESSION['mes'] = mes('У вас максимальный уровень амулета!');  
header('location: /shop/amulet/');
exit;}
  
  if($user['g'] < $amulet['gold']){
$_SESSION['mes'] = mes('Недостаточно золота!');  
header('location: /shop/amulet/');
exit;}


mysql_query('UPDATE `users` SET `g` = `g` - "'.$amulet_new['gold'].'" WHERE `id` = \''.$user['id'].'\'');
mysql_query('UPDATE `users` SET `str` = `str` + "'.$amulet_new['stat'].'",
                                    `vit` = `vit` + "'.$amulet_new['stat'].'",
                                    `def` = `def` + "'.$amulet_new['stat'].'",
                                    `amulet` = `amulet` + "1",
                                    `amulet_stat` = `amulet_stat` + "'.$amulet_new['stat'].'",
                                    `amulet_exp` = `amulet_exp` + "'.$amulet_new['exp'].'",
                                    `amulet_silver` = `amulet_silver` + "'.$amulet_new['silver'].'"                                    

                                     WHERE `id` = \''.$user['id'].'\'');
								 
$_SESSION['mes'] = mes('Амулет улучшен'); 
header('location: /shop/amulet/');
exit;
  
}

echo '<div class="title"> '.$title.' </div>';
      echo' '.$_SESSION['mes'].'  ';
    $_SESSION['mes']=NULL; //Удаляем сесию

echo'<div class="empty_block">
<font color="#90b0c0">

<table style="width:100%" cellspacing="0" cellpadding="5"><tr>
<td width="20%"> <img src="/images/ico/png/amulet1.png" alt="*"/> </td>
<td> <font color="#fff"><b>Амулет</b></font></br>
Качество: '.$user['amulet'].' из 55 </br>
+'.$user['amulet_stat'].' ко всем параметрам </br>
+'.$user['amulet_exp'].' к <img src="/images/ico/png/exp.png" alt="*"/> опыту </br>
+'.$user['amulet_silver'].' к <img src="/images/ico/png/silver.png" alt="*"/> серебру </br>
</td>
</tr></table> ';

if($user['amulet'] < '55'){
echo'<div class="link_center"><a href="/shop/amulet/?buy=true"> '.($user['amulet'] != '0' ? 'Улучшить за <img src="/images/ico/png/gold.png" alt="*" width="16"/> '.$amulet_new['gold'].'':'Купить за <img src="/images/ico/png/gold.png" alt="*" width="16"/> '.$amulet_new['gold'].'').' </a></div>
<center>Станет +'.($user['amulet_stat']+$amulet_new['stat']).' к параметрам, +<img src="/images/ico/png/exp.png" alt="*"/>'.($user['amulet_exp']+$amulet_new['exp']).', +<img src="/images/ico/png/silver.png" alt="*"/>'.($user['amulet_silver']+$amulet_new['silver']).'</center>';
}
echo'</font></div>
<div class="line"></div>
<div class="empty_block item_center">
Амулет увеличивает количество опыта и серебра, 
получаемые на арене, а так же повышает курс обмена золота на серебро
</div><div class="line"></div>';

echo'<div class="block_link"><a href="/shop/"><img src="/images/ico/png/back.png" alt="*"/> Назад к категориям </a></div>
<div class="line"></div>';
break;




   
case 'premium':
$title = 'Премиум-аккаунт';

$id = _string(_num($_GET['id']));
  if($id >= 1 && $id <= 6) {
    switch($id) {
case 1:
$cost = 90;
$time = 86400 * 1;
break;
case 2:
$cost = 250;
$time = 86400 * 3;
break;
case 3:
$cost = 500;
$time = 86400 * 7;
break;
case 4:
$cost = 1500;
$time = 86400 * 30;
break;
}
  

  
  if($user['g'] < $cost){
$_SESSION['mes'] = mes('Недостаточно золота!');  
header('location: /shop/premium/');
exit;}

  if($premium){
mysql_query('UPDATE `users` SET `g` = `g` - "'.$cost.'" WHERE `id` = "'.$user['id'].'" ');
mysql_query('UPDATE `premium` SET `time` = `time` + "'.$time.'" WHERE `user` = "'.$user['id'].'" ');   
$_SESSION['mes'] = mes('Вы успешно продлили премиум-аккаунт!');  
header('location: /shop/premium/');
exit;}

mysql_query('UPDATE `users` SET `g` = `g` - "'.$cost.'" WHERE `id` = "'.$user['id'].'" ');
mysql_query('INSERT INTO `premium` (`user`,
                                    `time`) VALUES ("'.$user['id'].'",
                                                   "'.(time()+$time).'")');    
mysql_query('UPDATE `users` SET `str` = `str` + 200,
                                `vit` = `vit` + 200,
                                `def` = `def` + 200 WHERE `id` = "'.$user['id'].'" ');
$_SESSION['mes'] = mes('Премиум-аккаунт активированный!');  
header('location: /shop/premium/');
exit;
  
}

echo '<div class="title"> '.$title.' </div>';
      echo' '.$_SESSION['mes'].'  ';
    $_SESSION['mes']=NULL; //Удаляем сесию

echo'<div class="empty_block">
<table> <tbody><tr>
<td width="14%">
<img src="/images/ico/premium.png" alt="*">
</td><td> 
<font color="#fff">Премиум-аккаунт</font> <br>
'.($premium ? '<font color="lime">Осталось: '._time($premium['time'] - time()).'</font> </br>':'').'
<font color="lime">+100%</font> <font color="#90b0c0">серебра</font> </br>
<font color="lime">+100%</font> <font color="#90b0c0">опыта себе и клану</font> </br>
<font color="lime">+200</font>  <font color="#90b0c0">к параметрам героя</font> 
</td></tr>
</tbody></table>
</div>
<div class="line"></div>

<div class="empty_block item_center">

  <div class="link_center"><a href="/shop/premium/?id=1">'.($premium ? 'продлить':'Купить').' за <img src="/images/ico/png/gold.png" alt="*"/>90</a></div>
  <font color="#909090"> на 24 часа</font>
  
  <div class="link_center"><a href="/shop/premium/?id=2">'.($premium ? 'продлить':'Купить').' за <img src="/images/ico/png/gold.png" alt="*"/>250</a></div>
  <font color="#909090"> на 3 дня</font>
  
  <div class="link_center"><a href="/shop/premium/?id=3">'.($premium ? 'продлить':'Купить').' за <img src="/images/ico/png/gold.png" alt="*"/>500</a></div>
  <font color="#909090"> на 7 дней</font>
  
  <div class="link_center"><a href="/shop/premium/?id=4">'.($premium ? 'продлить':'Купить').' за <img src="/images/ico/png/gold.png" alt="*"/>1500</a></div>
  <font color="lime"> на 30 дней</font>
  
</div>
<div class="line"></div>';

echo'<div class="block_link"><a href="/shop/"><img src="/images/ico/png/back.png" alt="*"/> Назад к категориям </a></div>
<div class="line"></div>';
break;

























////////////////////////////////
// КУЗНИЦА ////////////////////
  case 'runes':
$title = 'Торговец рунами';    
echo'<div class="title">'.$title.'</div>';
echo' '.$_SESSION['mes'].' ';
    $_SESSION['mes']=NULL; //Удаляем сесию



$id = _string(_num($_GET['id']));

if($id) {

  $inv = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$user['id'].'" AND `id` = "'.$id.'" AND `equip` = "1" ');
  $inv = mysql_fetch_array($inv);
 
  if(!$inv) {
header('location: /shop/runes/');
$_SESSION['mes'] = mes('Вы не можете наносить руну на неодетую вещь!');	
exit;}
 
  $item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$inv['item'].'"');    
  $item = mysql_fetch_array($item);


  


$rune = _string(_num($_GET['rune']));
  if($rune >= 1 && $rune <= 6) {
  
    switch($rune) {
case 1:
$cost = 100;
$rune_stats = 15;
break;
case 2:
$cost = 300;
$rune_stats = 30;
break;
case 3:
$cost = 500;
$rune_stats = 60;
break;
case 4:
$cost = 2000;
$rune_stats = 200;
break;
case 5:
$cost = 5000;
$rune_stats = 500;
break;
case 6:
$cost = 10000;
$rune_stats = 1000;
break;
}
  if($rune <= $inv['rune']){
  header('location: /shop/runes/'.$id.'');
$_SESSION['mes'] = mes('Данная руна уже установленная!');	
exit;}
  
  if($rune > $inv['quality']){
  header('location: /shop/runes/'.$id.'');
$_SESSION['mes'] = mes('Данную руну невозможно установить!');	
exit;}
  if($cost && $user['g'] >= $cost) {
mysql_query('UPDATE `users` SET `g` = "'.($user['g'] - $cost).'",
                                `str` = "'.($user['str'] + $rune_stats).'",
                                `vit` = "'.($user['vit'] + $rune_stats).'",
                                `def` = "'.($user['def'] + $rune_stats).'"  WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `inv`   SET `_str` = "'.($inv['_str'] + $rune_stats).'",
								`_vit` = "'.($inv['_vit'] + $rune_stats).'",
								`_def` = "'.($inv['_def'] + $rune_stats).'",
                                               `rune` = "'.$rune.'" WHERE `id` = "'.$inv['id'].'"');

header('location: /shop/runes/'.$id.'');
$_SESSION['mes'] = mes('Руна успешно установлена!');	
exit;
}else{
header('location: /shop/runes/'.$id.'');
$_SESSION['mes'] = mes('Недостаточно золота!');
exit;
}
  
}

switch($item['quality']) {
case 1:
$quality = 'Обычный';
$quality_color = '#999999';
break;
case 2:
$quality = 'Необычный';
$quality_color = '#B1D689';
break;
case 3:
$quality = 'Редкий';
$quality_color = '#6BA0E7';
break;
case 4:
$quality = 'Эпический';
$quality_color = '#C780DB';
break;
case 5:
$quality = 'Легендарный';
$quality_color = '#FF8E94';
break;
case 6:
$quality = 'Мифический';
$quality_color = '#FE7E01';
break;
}

echo'<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>
  <td width="15%"><img src="/images/items/'.$item['id'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$item['quality'].'.png" alt="*"/> <a href="/item/'.$inv['id'].'/"> '.$item['name'].' </a> '.($inv['smith'] > 0 ? '<small><font color="#90b0c0"> +'.$inv['smith'].'</font></small>':'').'
  <br/><small><img src="/images/ico/png/up.png" alt="*" width="12"/><font color="#fff">'.$item['level'].' ур, </font>
  <font color="'.$quality_color.'"> '.$quality.' </font></small>';
  
  
    if($inv['rune']) {
  
    switch($inv['rune']) {
case 1:
$rune_stats = 15; 
$rune_color = '#999999';
break;
case 2:
$rune_stats = 30; 
$rune_color = '#B1D689';
break;
case 3:
$rune_stats = 60;
$rune_color = '#6BA0E7'; 
break;
case 4:
$rune_stats = 200; 
$rune_color = '#C780DB';
break;
case 5:
$rune_stats = 500; 
$rune_color = '#FF8E94';
break;
case 6:
$rune_stats = 1000; 
$rune_color = '#FE7E01';
break;
}
    




echo'<br/>
<img src="/images/ico/rune/small_'.$inv['rune'].'.png" alt="*"/> <font color="'.$rune_color.'"><small> +'.$rune_stats.' к параметрам </small></font>';
	} 
  echo'</td></tr></table>
  </div><div class="line"></div>';

echo'<div class="empty_block">
<font color="#90b0c0">
  <img src="/images/ico/png/attack.png" alt="*"/> Сила:  '.$inv['_str'].' <br/>
  <img src="/images/ico/png/hp.png" alt="*"/> Жизнь: '.$inv['_vit'].' <br/>
  <img src="/images/ico/png/def.png" alt="*"/> Защита: '.$inv['_def'].' <br/>
  </font>
</div><div class="line"></div>';




$rune_quality=$item['quality']; //Можно ставить качество руны не выше чем качество вещи
if($inv['rune'] != $inv['quality']){
  for($i = $inv['rune']+1; $i <= $rune_quality; $i++) {

  switch($i) {
case 1:
$quality = 'Обычное качество'; 
$quality_color = "#999999";
$cost = 100;
$rune_stats = 15;
break;
case 2:
$quality = 'Необычное качество'; 
$quality_color = "#B1D689";
$cost = 300;
$rune_stats = 30;
break;
case 3:
$quality = 'Редкое качество'; 
$quality_color = "#6BA0E7";
$cost = 500;
$rune_stats = 60;
break;
case 4:
$quality = 'Эпическое качество'; 
$quality_color = "#C780DB";
$cost = 2000;
$rune_stats = 200;
break;
case 5:
$quality = 'Легендарное качество'; 
$quality_color = "#FF8E94";
$cost = 5000;
$rune_stats = 500;
break;
case 6:
$quality = 'Мифическое качество'; 
$quality_color = "#FE7E01";
$cost = 10000;
$rune_stats = 1000;
break;
  }


echo'
<div class="empty_block">
  <table cellpadding="0" cellspacing="0">
  <tr>
  <td><img src="/images/ico/rune/'.$i.'.png" alt="*"/></td>
  <td> <font color="'.$quality_color.'"> '.$quality.' </font>
  <br/>
  Бонус: <font color="#9c9"> +'.$rune_stats.' </font> к параметрам
  </td></tr></table>
  <br/>
  <div class="link_center"><a href="/shop/runes/'.$inv['id'].'/'.$i.'/"> <img src="/images/ico/png/gold.png" alt="*" width="18"/> '.$cost.' </a></div>
</div></div><div class="line"></div>';
}	

  }else{
echo' <div class="empty_block item_center"> Снаряжение имеет руну максимального качества. 
</div><div class="line"></div>';
}
  
echo'<div class="block_link"><a href="/shop/runes/"><img src="/images/ico/png/back.png" alt="*"/> Назад к выбору вещей </a></div>
<div class="line"></div>';

}else{
echo' '.$_SESSION['mes'].' ';
    $_SESSION['mes']=NULL; //Удаляем сесию


$q = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$user['id'].'" AND `equip` = "1" ');
$items = mysql_result($q,0);

  if($items > 0) {
    for($w = 1; $w < 9; $w++) {
        if($user['w_'.$w]) {
        
    $inv = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$w].'" ');      
    $inv = mysql_fetch_array($inv);

        $item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$inv['item'].'"');
        $item = mysql_fetch_array($item);

  switch($inv['quality']) {
case 1:
$quality = 'Обычный';
$quality_color = '#999999';
break;
case 2:
$quality = 'Необычный';
$quality_color = '#B1D689';
break;
case 3:
$quality = 'Редкий';
$quality_color = '#6BA0E7';
break;
case 4:
$quality = 'Эпический';
$quality_color = '#C780DB';
break;
case 5:
$quality = 'Легендарный';
$quality_color = '#FF8E94';
break;
case 6:
$quality = 'Мифический';
$quality_color = '#FE7E01';
break;
}

 echo'<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>';
echo'  
  <td width="15%"><img src="/images/items/'.$inv['item'].'.png" alt="*"/></td>
  <td> <img src="/images/ico/quality/'.$inv['quality'].'.png" alt="*"/> <a href="/item/'.$inv['id'].'/">'.$item['name'].'</a> '.($inv['smith'] > 0 ? '<small><font color="#90b0c0"> +'.$inv['smith'].'</font></small>':'').'
  <br/><small> <font color="#fff"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур, </font> <font color="'.$quality_color.'">'.$quality.'</font>';





  if($inv['rune']) {
  
    switch($inv['rune']) {
case 1:
$rune_stats = 15; 
$rune_color = '#999999';
break;
case 2:
$rune_stats = 30; 
$rune_color = '#B1D689';
break;
case 3:
$rune_stats = 60;
$rune_color = '#6BA0E7'; 
break;
case 4:
$rune_stats = 200; 
$rune_color = '#C780DB';
break;
case 5:
$rune_stats = 500; 
$rune_color = '#FF8E94';
break;
case 6:
$rune_stats = 1000; 
$rune_color = '#FE7E01';
break;
}
    




echo'<br/>
<img src="/images/ico/rune/small_'.$inv['rune'].'.png" alt="*"/> <font color="'.$rune_color.'"> +'.$rune_stats.' к параметрам</font>';
}
echo'</small></td>
</tr></table>
<br/>
<div class="link_center"><a href="/shop/runes/'.$inv['id'].'/">Выбрать</a></div>
</div><div class="line"></div>';
}
		
}
}else{
  
echo'<div class="empty_block item_center">
Снаряжение не одето или улучшено максимально.
</div><div class="line"></div>';
  }
echo'<div class="block_link"><a href="/shop/"><img src="/images/ico/png/back.png" alt="*"/> Назад к категориям </a></div>
<div class="line"></div>';
}


break;
  
  
  
  
  
  
case 'smith':
$title = 'Повышение заточки';    
echo'<div class="title">'.$title.'</div>';

$id = _string(_num($_GET['id']));
if($id) {
  $inv = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$user['id'].'" AND `id` = "'.$id.'" AND `equip` = "1" ');
  $inv = mysql_fetch_array($inv);
 
  if(!$inv) {//Если вещь не одета
header('location: /shop/smith/');
$_SESSION['mes'] = mes('Вещь не одета!');	
exit;
}
 
  $item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$inv['item'].'"');    
  $item = mysql_fetch_array($item);

  switch($item['quality']) {
case 1:
$quality = 'Обычный';
$quality_color = "#999999";
break;
case 2:
$quality = 'Необычный';
$quality_color = "#B1D689";
break;
case 3:
$quality = 'Редкий';
$quality_color = "#6BA0E7";
break;
case 4:
$quality = 'Эпический';
$quality_color = "#C780DB";
break;
case 5:
$quality = 'Легендарный';
$quality_color = "#FF8E94";
break;
case 6:
$quality = 'Мифический';
$quality_color = "#FE7E01";
break;
}





  switch($inv['smith']) {
case 0:
$cost   = 100;//Сумма
$value  = 's';
break;
case 1:
$cost   = 300;//Сумма
$value  = 's';
break;
case 2:
$cost   = 600;
$value  = 's';
break;
case 3:
$cost   = 900;
$value  = 's';
break;
case 4:
$cost   = 15;
$value  = 'g';
break;
case 5:
$cost   =  1200;
$value  = 's';
break;
case 6:
$cost   = 1600;
$value  = 's';
break;
case 7:
$cost   = 2400;
$value  = 's';
break;
case 8:
$cost   = 50;
$value  = 'g';
break;
case 9:
$cost   = 4000;
$value  = 's';
break;
case 10:
$cost   =  6000;
$value  = 's';
break;
case 11:
$cost   = 10000;
$value  = 's';
break;
case 12:
$cost   = 100;
$value  = 'g';
break;
case 13:
$cost   = 16000;
$value  =  's';
break;
case 14:
$cost   =  22000;
$value  = 's';
break;
case 15:
$cost  = 28000;
$value  = 's';
break;
case 16:
$cost  = 500;
$value  = 'g';
break;
case 17:
$cost  = 37000;
$value  = 's';
break;
case 18:
$cost  = 44000;
$value  = 's';
break;
case 19:
$cost  = 52000;
$value  = 's';
break;
case 20:
$cost   =  1000;
$value  = 'g';
break;
case 21:
$cost   =  20;
$value  = 'g';
break;
case 22:
$cost   =  20;
$value  = 'g';
break;
case 23:
$cost   =  20;
$value  = 'g';
break;
case 24:
$cost   =  20;
$value  = 'g';
break;
case 25:
$cost   =  20;
$value  = 'g';
break;
case 26:
$cost   =  20;
$value  = 'g';
break;
case 27:
$cost   =  20;
$value  = 'g';
break;
case 28:
$cost   =  20;
$value  = 'g';
break;
case 29:
$cost   =  20;
$value  = 'g';
break;
case 30:
$cost   =  20;
$value  = 'g';
break;
case 31:
$cost   =  20;
$value  = 'g';
break;
case 32:
$cost   =  20;
$value  = 'g';
break;
case 33:
$cost   =  20;
$value  = 'g';
break;
case 34:
$cost   =  20;
$value  = 'g';
break;
case 35:
$cost   =  20;
$value  = 'g';
break;
case 36:
$cost   =  20;
$value  = 'g';
break;
case 37:
$cost   =  20;
$value  = 'g';
break;
case 38:
$cost   =  20;
$value  = 'g';
break;
case 39:
$cost   =  20;
$value  = 'g';
break;
case 40:
$cost   =  20;
$value  = 'g';
break;
case 41:
$cost   =  20;
$value  = 'g';
break;
case 42:
$cost   =  20;
$value  = 'g';
break;
case 43:
$cost   =  20;
$value  = 'g';
break;
case 44:
$cost   =  20;
$value  = 'g';
break;
case 45:
$cost   =  20;
$value  = 'g';
break;
case 46:
$cost   =  20;
$value  = 'g';
break;
case 47:
$cost   =  20;
$value  = 'g';
break;
case 48:
$cost   =  20;
$value  = 'g';
break;
case 49:
$cost   =  20;
$value  = 'g';
break;
case 50:
$cost   =  20;
$value  = 'g';
break;
case 51:
$cost   =  20;
$value  = 'g';
break;
case 52:
$cost   =  20;
$value  = 'g';
break;
case 53:
$cost   =  20;
$value  = 'g';
break;
case 54:
$cost   =  20;
$value  = 'g';
break;
case 55:
$cost   =  20;
$value  = 'g';
break;
case 56:
$cost   =  20;
$value  = 'g';
break;
case 57:
$cost   =  20;
$value  = 'g';
break;
case 58:
$cost   =  20;
$value  = 'g';
break;
case 59:
$cost   =  20;
$value  = 'g';
break;
case 60:
$cost   =  20;
$value  = 'g';
break;
case 61:
$cost   =  20;
$value  = 'g';
break;
case 62:
$cost   =  20;
$value  = 'g';
break;
case 63:
$cost   =  20;
$value  = 'g';
break;
case 64:
$cost   =  20;
$value  = 'g';
break;
case 65:
$cost   =  20;
$value  = 'g';
break;
case 66:
$cost   =  20;
$value  = 'g';
break;
case 67:
$cost   =  20;
$value  = 'g';
break;
case 68:
$cost   =  20;
$value  = 'g';
break;
case 69:
$cost   =  20;
$value  = 'g';
break;
case 70:
$cost   =  20;
$value  = 'g';
break;
case 71:
$cost   =  20;
$value  = 'g';
break;
case 72:
$cost   =  20;
$value  = 'g';
break;
case 73:
$cost   =  20;
$value  = 'g';
break;
case 74:
$cost   =  20;
$value  = 'g';
break;
case 75:
$cost   =  20;
$value  = 'g';
break;
case 76:
$cost   =  20;
$value  = 'g';
break;
case 77:
$cost   =  20;
$value  = 'g';
break;
case 78:
$cost   =  20;
$value  = 'g';
break;
case 79:
$cost   =  20;
$value  = 'g';
break;
case 80:
$cost   =  20;
$value  = 'g';
break;

}


   $smith = 3;//На сколько параметров заточить
  if($_GET['start'] == true && $inv['smith'] < "80") {//Улучшаем вещь
  
  
      if($value == 's') {//Серебро
      if($user['s'] < $cost) {
header('Location: /shop/smith/'.$id.'');
$_SESSION['mes'] = mes('Недостаточно ресурсов!');
exit;
}else{
mysql_query('UPDATE `users` SET `s` = `s` - '.$cost.' WHERE `id` = "'.$user['id'].'"'); 	
}
}

      if($value == 'g') {//Золото
      if($user['g'] < $cost) {
header('Location: /shop/smith/'.$id.'');
$_SESSION['mes'] = mes('Недостаточно ресурсов!');
exit;
}else{
mysql_query('UPDATE `users` SET `g` = `g` - '.$cost.' WHERE `id` = "'.$user['id'].'"'); 	
}
}	  
   
  

 
mysql_query('UPDATE `users` SET `str` = `str` + "'.$smith.'",
                                 `vit` = `vit` + "'.$smith.'",
                                 `def` = `def` + "'.$smith.'" WHERE `id` = "'.$user['id'].'"'); 	                                 
mysql_query('UPDATE `inv` SET `smith` = `smith` + 1,
                               `_str` = "'.($inv['_str'] + $smith).'",
                               `_vit` = "'.($inv['_vit'] + $smith).'",
                               `_def` = "'.($inv['_def'] + $smith).'" WHERE `id` = "'.$inv['id'].'"');

header('Location: /shop/smith/'.$id.'');
$_SESSION['mes'] = mes('Вещь успешно заточена!');
exit;}
  

  
echo' '.$_SESSION['mes'].' ';
    $_SESSION['mes']=NULL; //Удаляем сесию

echo'<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>
  <td width="15%"><img src="/images/items/'.$item['id'].'.png" alt="*"/></td>
  <td><img src="/images/ico/quality/'.$item['quality'].'.png" alt="*"/> <a href="/item/'.$inv['id'].'/"> '.$item['name'].' </a> '.($inv['smith'] > 0 ? '<small><font color="#90b0c0"> +'.$inv['smith'].'</font></small>':'').'
  <br/><small><img src="/images/ico/png/up.png" alt="*" width="12"/><font color="#fff">'.$item['level'].' ур, </font>
  <font color="'.$quality_color.'"> '.$quality.' </font></small>';
  
    if($inv['rune']) {
  
    switch($inv['rune']) {
case 1:
$rune_stats = 15; 
$rune_color = '#999999';
break;
case 2:
$rune_stats = 30; 
$rune_color = '#B1D689';
break;
case 3:
$rune_stats = 60;
$rune_color = '#6BA0E7'; 
break;
case 4:
$rune_stats = 200; 
$rune_color = '#C780DB';
break;
case 5:
$rune_stats = 500; 
$rune_color = '#FF8E94';
break;
case 6:
$rune_stats = 1000; 
$rune_color = '#FE7E01';
break;
}
    




echo'<br/>
<img src="/images/ico/rune/small_'.$inv['rune'].'.png" alt="*"/> <font color="'.$rune_color.'"> <small>+'.$rune_stats.' к параметрам </small></font>';
}
	
 echo' </td></tr></table>
  </div><div class="line"></div>';

echo'<div class="empty_block">
<font color="#90b0c0">
  <img src="/images/ico/png/attack.png" alt="*"/> Сила:  '.$inv['_str'].' <br/>
  <img src="/images/ico/png/hp.png" alt="*"/> Жизнь: '.$inv['_vit'].' <br/>
  <img src="/images/ico/png/def.png" alt="*"/> Защита: '.$inv['_def'].' <br/>
  </font>
</div><div class="line"></div>';


echo'<div class="empty_block item_center">
  Каждая заточка дает <font color="#90c090"> +'.$smith.' </font> к каждому параметру героя.
  '.($inv['smith'] >= 80 ? '<div class="link_center_h"><a> Вещь заточена </a></div>':'<div class="link_center">
  <a href="/shop/smith/'.$inv['id'].'/?start=true">  
  <img src="/images/ico/png/'.($value == 'g' ? 'gold':'silver').'.png" alt="*" width="18"/> '.$cost.'</a></div>').'
  
  </div><div class="line"></div>';


echo'<div class="block_link"><a href="/shop/smith/"><img src="/images/ico/png/back.png" alt="*"/> Назад к кузнецу </a></div>
<div class="line"></div>';
}else{

$q = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$user['id'].'" AND `equip` = "1" ');
$items = mysql_result($q,0);

  if($items > 0) {
    for($w = 1; $w < 9; $w++) {
     if($user['w_'.$w]) {
        
    $inv = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$w].'" ');      
    $inv = mysql_fetch_array($inv);

        $item = mysql_query('SELECT * FROM `items` WHERE `id` = "'.$inv['item'].'"');
        $item = mysql_fetch_array($item);

  switch($inv['quality']) {
case 1:
$quality = 'Обычный';
$quality_color = '#999999';
break;
case 2:
$quality = 'Необычный';
$quality_color = '#B1D689';
break;
case 3:
$quality = 'Редкий';
$quality_color = '#6BA0E7';
break;
case 4:
$quality = 'Эпический';
$quality_color = '#C780DB';
break;
case 5:
$quality = 'Легендарный';
$quality_color = '#FF8E94';
break;
case 6:
$quality = 'Мифический';
$quality_color = '#FE7E01';
break;
}

 echo'<div class="empty_block">
<table cellpadding="0" cellspacing="0">
<tr>';
echo'  
  <td width="15%"><img src="/images/items/'.$inv['item'].'.png" alt="*"/></td>
  <td> <img src="/images/ico/quality/'.$inv['quality'].'.png" alt="*"/> <a href="/item/'.$inv['id'].'/">'.$item['name'].'</a> '.($inv['smith'] > 0 ? '<small><font color="#90b0c0"> +'.$inv['smith'].'</font></small>':'').'
  <br/><small> <font color="#fff"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур, </font> <font color="'.$quality_color.'">'.$quality.'</font>';





  if($inv['rune']) {
  
    switch($inv['rune']) {
case 1:
$rune_stats = 15; 
$rune_color = '#999999';
break;
case 2:
$rune_stats = 30; 
$rune_color = '#B1D689';
break;
case 3:
$rune_stats = 60;
$rune_color = '#6BA0E7'; 
break;
case 4:
$rune_stats = 200; 
$rune_color = '#C780DB';
break;
case 5:
$rune_stats = 500; 
$rune_color = '#FF8E94';
break;
case 6:
$rune_stats = 1000; 
$rune_color = '#FE7E01';
break;
}
    




echo'<br/>
<img src="/images/ico/rune/small_'.$inv['rune'].'.png" alt="*"/> <font color="'.$rune_color.'"> +'.$rune_stats.' к параметрам</font>';
}
echo'</small></td>
</tr></table>
<br/>
<div class="link_center"><a href="/shop/smith/'.$inv['id'].'/">Выбрать</a></div>
</div><div class="line"></div>';
}
		
}
}else{
  
echo'<div class="empty_block item_center">
Снаряжение не одето или улучшено максимально.
</div><div class="line"></div>';
  }
echo'<div class="block_link"><a href="/shop/"><img src="/images/ico/png/back.png" alt="*"/> Назад к категориям </a></div>
<div class="line"></div>';
}


  break;
}
include './system/f.php';
?>