<?php
$get = $_GET['id'];
$player_name = $_GET['pid'];
$art = $_GET['art'];

include_once('../lib/conn.php');

$sql = mysql_query("SELECT `id` FROM `player`.`player` WHERE `name`='".$player_name."';");
$res = mysql_fetch_array($sql);
$user_id = $res['id'];

if(strlen($get)==5) {
	$value = substr($get, -1);
} else {
	$value = substr($get, -2);
}

$sql2 = mysql_query("SELECT `vnum`, `socket0`, `socket1`, `socket2`, `socket3`, `socket4`, `socket5`, `attrtype0`, `attrvalue0`, `attrtype1`, `attrvalue1`, `attrtype2`, `attrvalue2`, `attrtype3`, `attrvalue3`, `attrtype4`, `attrvalue4`, `attrtype5`, `attrvalue5`, `attrtype6`, `attrvalue6` FROM `player`.`item` WHERE `owner_id`='".$user_id."' AND `window`='".$art."' AND `pos`='".$value."';");
if($sql2) {
	$res2 = mysql_fetch_array($sql2);
	include_once('../items.inc.php');
	include_once('../boni.inc.php');
	$result = '<div id="eqc_head"></div>
			   <div id="equip_conn">
			   <div id="eqc_name">'.htmlentities($itemListNr[$res2['vnum']]).'</div>
			   <div id="eqc_boni">';
		
	for($i=0; $i<=6; $i++) {
		if(isset($boniListNr[$res2['attrtype'.$i]])) {
			if(substr($boniListNr[$res2['attrtype'.$i]], -1)=='%') {
				$boni_desc = substr($boniListNr[$res2['attrtype'.$i]], 0, -1);
				$boni_value = $res2['attrvalue'.$i].'%';
			} else {
				$boni_desc = $boniListNr[$res2['attrtype'.$i]];
				$boni_value = $res2['attrvalue'.$i];
			}
			$result .= '<p>'.htmlentities($boni_desc).$boni_value.'</p>';
		}
	}
	
	$result .= '
		</div>
		<div id="eqc_steine">';
		for($k=0; $k<=5; $k++) {
			if(strlen($res2['socket'.$k])>3) {
				if(file_exists('../img/item/'.$res2['socket'.$k].'.png')) {
					$result .= '<p><img src="img/item/'.$res2['socket'.$k].'.png"></p>';
				}
			}
		}
		
		$result .= '</div></div><div id="eqc_foot"></div>';
		
	echo $result;
}
?>