<?
include './system/common.php';  
include './system/functions.php';
include './system/user.php';
    
if(!$user) {
header('location: /');   
exit;}

$id = _string(_num($_GET['id']));
  if($id && $id != $user['id']) {
    $i = mysql_query('SELECT * FROM `users` WHERE `id` = "'.$id.'"');
    $i = mysql_fetch_array($i);
if(!$i) {    
header('location: /user/');
exit; }

$title = 'Снаряжение '.$i['login'];
}else{
$i = $user;
$title = 'Снаряжение';
}

include './system/h.php';  
echo'<div class="title">'.$title.'</div>';
     echo' '.$_SESSION['mes'].'  ';
    $_SESSION['mes']=NULL; //Удаляем сесию
    
    for($w = 1; $w < 9; $w++) {
      
$w_name = [	'1'=>'Голова',
		'2'=>'Плечи',
		'3'=>'Торс',
		'4'=>'Перчатки',
		'5'=>'Левая рука',
		'6'=>'Правая рука',
		'7'=>'Ноги',
		'8'=>'Обувь'
		];


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


        if($i['w_'.$w]) {
        
    $inv = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$i['w_'.$w].'"');      
    $inv = mysql_fetch_array($inv);

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

  $quality = [	'1'=>'Обычный',
				'2'=>'Необычный',
				'3'=>'Редкий',
				'4'=>'Эпический',
				'5'=>'Легендарный',
				'6'=>'Мифический'
		];
$quality_color=['1'=>'#999999',
				'2'=>'#B1D689',
				'3'=>'#6BA0E7',
				'4'=>'#C780DB',
				'5'=>'#FF8E94',
				'6'=>'#FE7E01'
		];

 
echo'  
  <td width="15%"><img src="/images/items/'.$inv['item'].'.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> <font color="#fff"><img src="/images/ico/png/up.png" alt="*" width="12"/>'.$item['level'].' ур, </font> <font color="'.$quality_color[$item['quality']].'">'.$quality[$item['quality']].'</font>';


    if($user['id'] != $item['user']) {
      
      $equip_item = mysql_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
      $equip_item = mysql_fetch_array($equip_item);        
    
  if(($equip_item['_str']+$equip_item['_vit']+$equip_item['_def']) - ($inv['_str']+$inv['_vit']+$inv['_def']) > 0) {
echo'<font color="#c06060">-'.(($equip_item['_str']+$equip_item['_vit']+$equip_item['_def']) - ($inv['_str']+$inv['_vit']+$inv['_def'])).'</font>';
 }else{
	 if($user['id'] != $inv['user']){
	 echo'  <font color="#3c3">+'.(($inv['_str']+$inv['_vit']+$inv['_def']) - ($equip_item['_str']+$equip_item['_vit']+$equip_item['_def'])).'</font>';}
 }
}


  if($inv['rune']) {


$rune_stats = [ '1'=>'15',
				'2'=>'30',
				'3'=>'60',
				'4'=>'200',
				'5'=>'500',
				'6'=>'1000'
		];
$rune_color=[   '1'=>'#999999',
				'2'=>'#B1D689',
				'3'=>'#6BA0E7',
				'4'=>'#C780DB',
				'5'=>'#FF8E94',
				'6'=>'#FE7E01'
		];  


echo'<br/>
<img src="/images/ico/rune/small_'.$inv['rune'].'.png" alt="*"/> <font color="'.$rune_color[$inv['rune']].'"> +'.$rune_stats[$inv['rune']].' к параметрам</font>';
}
echo'</small></td>';
}else{     
echo' <td width="15%"><img src="/images/item_null.png" alt="*"/></td>
<td> '.$w_name[$w].' </td>';     
}

echo'</tr></table>
</div>
<div class="line"></div>';
}
  
include './system/f.php';
?>