Просмотр файла element_item.php

Размер файла: 11.33Kb
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }

	if (!$id) {
		$title = 'Вещь не найдена';
		$error1 = '<span class="small">Выбранная Вами вещь не существует, или была удалена</span>';
		require_once 'element_error_page.php';
		exit;
	}
	
	$item_id = cache_item($id);
	
	if (!$item_id) {
		$title = 'Вещь не найдена';
		$error1 = '<span class="small">Выбранная Вами вещь не существует, или была удалена</span>';
		require_once 'element_error_page.php';
		exit;
	}
	
	if ($item_id['lost_bag'] == 2 AND $user['lost_privilege'] != 3) {
		$title = 'Вещь не найдена';
		$error1 = '<span class="small">Выбранная Вами вещь не существует, или была удалена</span>';
		require_once 'element_error_page.php';
		exit;
	}
	
	require_once './element_function/element_function_item.php';
	$genaration_params = item_generation_params($item_id['lost_strlen'], $item_id['lost_heatpoints'], $item_id['lost_protection'], $item_id['lost_comparison']);
	$owner = ($item_id['lost_user'] == $user['lost_id']) ? $user : cache_user($item_id['lost_user']);
	$quality = quality_item_name($item_id['lost_quality']);
	$item_new = ($item_id['lost_new'] == 0) ? 'Новый' : 'Личный';
	
	$wear_item = users_wear_item($user['lost_id']);
	$shoot_item = users_shoot_item($user['lost_id']); // Массив с вещами в рюкзаке
	
	$bla = item_params_type($item_id['lost_mesto']);
	$enchants = item_enchants_quality($item_id['lost_enchants'], $bla[1]);
	
$title = $item_id['lost_name'];
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
$count_item = count($shoot_item);	
	
	if ($go == 'shoot') 
		{
		if ($count_item < $max_count_item)
			{
			shoot_item($user, $item_id, $shoot_item, $wear_item, '/equipment?id='.$user['lost_id']);
			}
		else 
		{
			echo '<div class="nfl p5 mb5 mt5 small white cntr mlra">';
			echo 'Вы не можете снять вещь, рюкзак полон.';
		}
	}
	
	if ($go == 'wear') {
		if ($item_id['lost_quality'] < 3 AND $item_id['lost_new'] == 0) {
			if (isset($_GET['ok'])) {
				wear_item($user, $item_id, $shoot_item, $wear_item, '/bag', 1);
			} else {
				echo '<div class="nfl p5 mb5 mt5 small white cntr mlra">';
				echo 'Если Вы наденете эту вещь, она станет личной. Подтвердите что вы хотите надеть эту вещь';
				echo '<div class="mt5"><a class="button w30 mr2" href="/item?id='.$id.'&go=wear&ok">Да</a> <a class="button w30 ml2" href="/item?id='.$id.'">Нет</a></div>';
				echo '</div>';
			}
		} else wear_item($user, $item_id, $shoot_item, $wear_item, '/bag', 0);
	}
	
	if ($go == 'delete') {
		if ($item_id['lost_user'] == $user['lost_id'] AND $item_id['lost_bag'] == 0) {
			$summa_del = ((int)(($genaration_params['summa'] / 100) * 50));
			if ($item_id['lost_quality'] > 1) {
				if (isset($_GET['ok'])) {
					delete_item($user, $item_id, $shoot_item, true);
				} else {
					echo '<div class="nfl p5 mb5 mt5 small white cntr mlra">';
					echo 'Вы уверены что хотите продать эту вещь?';
					echo '<div class="mt5"><a class="button w30 mr2" href="/item?id='.$id.'&go=delete&ok">Да</a> <a class="button w30 ml2" href="/item?id='.$id.'">Нет</a></div>';
					echo '</div>';
				}
			} else {
				delete_item($user, $item_id, $shoot_item, true);
			}
		}
	}
	
	if ($go == 'shot_auction') {
		AuctionItemCancel($user['lost_id'], $shoot_item, $item_id, '/item?id='.$id);
	}
	
	
	// Выкладываем вещь на аукцион
	if ($go == 'auction') {
		if ($item_id['lost_user'] == $user['lost_id'] AND $item_id['lost_bag'] == 0 AND $item_id['lost_quality'] >= 3) {
			$cenaa = array(3 => 200, 4 => 500, 5 => 2000);
			$min_cena = (int)(($cenaa[$item_id['lost_quality']] / 100) * 90);
			
			if (isset($_GET['ok'])) {
				$gold1 = (isset($_POST['cena_gold']) AND is_numeric($_POST['cena_gold']) AND $_POST['cena_gold'] > 0) ? (int)$_POST['cena_gold'] : 0;
			
				if ($gold1 < $min_cena) $error = 'Минимальная цена этой вещи: <img src="/images/icons/gold.png">'.$min_cena.' золота';
			
				if (!isset($error)) {
						$item_id['lost_bag'] = 3;
						mysql_query("UPDATE `element_item` SET `lost_bag` = '3' WHERE `lost_id` = '$id' LIMIT 1");
						mysql_query("INSERT INTO `element_auction` SET `lost_id` = '$id',
																	   `lost_quality` = '$item_id[lost_quality]',
																	   `lost_mesto` = '$item_id[lost_mesto]',
																	   `lost_gold` = '$gold1',
																	   `lost_time` = '".time()."',
																	   `lost_user` = '$user[lost_id]'");
						unset($shoot_item[$id]);
						writecache('element_shoot_item_user_id'.$user['lost_id'], $shoot_item);
						header('Location: /item?id='.$id);
						exit;
				} else echo '<div class="nfl small p5 mb5 red small cntr mlra">'.$error.'</div>';
			
			} else {
			echo '<div class="nfl p5 mb5 small mt5 mlra">';
			echo '<table><td><img width="50" height="50" src="'.$item_id['lost_avatar'].'"></td>';
			echo '<td class="small" valign="top">';
			echo '<span class="ml5 small yellow1">'.$quality['image'].' '.$quality['name'].', '.$item_new.'</span><br/>';
			echo '<span class="ml5 small yellow1">'.$quality['image'].' '.$item_id['lost_name'].'</span><br/>';
			echo '<span class="ml5 small yellow1">'.$quality['image'].' '.name_item_mesto($item_id['lost_mesto']).'</span>';
			echo '</td></table><div class="hr mb5"></div>';
			echo '<div class="small white">';
			echo '<img src="/images/icons/strlen.png"> <span>Сила: </span><span class="yellow1">'.$genaration_params['strlen'].' <span class="ccc">('.$genaration_params['strlen_pr'].'%)</span></span><br/>';
			echo '<img src="/images/icons/heatpoints.png"> <span>Здоровье: </span><span class="yellow1">'.$genaration_params['heatpoints'].' <span class="ccc">('.$genaration_params['heatpoints_pr'].'%)</span></span><br/>';
			echo '<img src="/images/icons/protection.png"> <span>Защита: </span><span class="yellow1">'.$genaration_params['protection'].' <span class="ccc">('.$genaration_params['protection_pr'].'%)</span></span><br/>';
			echo '<img src="/images/icons/1.gif"> <span>Общая сумма: </span><span class="yellow1">'.$genaration_params['summa'].'</span>';
			echo '<div class="hr mt5 mb5"></div>';
			echo '- <span>Чары: '.(($enchants) ? $enchants['image'].'<span class="moderator">+'.$enchants['params'].' </span>'.$enchants['name'].'' : '<span class="gray1">не установлено</span>').'</span><br/>';
			echo '- <span>Сравнение: <span class="moderator">'.$item_id['lost_comparison'].'</span> ур. (+'.(($item_id['lost_comparison'] > 0) ? $item_id['lost_comparison'] * 5 : '0').'%)</span>';
			echo '<div class="hr mt5 mb5"></div>';
			echo '</div>';
			
			echo '<div class="white mb5 mt5 cntr">';
			echo '<form method="post" action="/item?id='.$id.'&go=auction&ok">
			  <label class="bl mb5 ccc">
				<img src="/images/icons/gold.png"> Цена:<br/>
				<input class="fdark w50" type="text" name="cena_gold" value="" size="20" maxlength="6">
			  </label>';
			echo '<span class="button w40"><input type="submit" class="ttl" name="submit" value="Выставить"/></span></form>';
			echo '</div>';
			echo '<div class="hr mt5 mb5"></div>';
			echo '<div class="game-master cntr">Минимальная цена: <img src="/images/icons/gold.png">'.$min_cena.' золота</div>';
			
			echo '</div>';
			require_once './element_include/element_foot_user_true.php';
			exit;
			}
		}
	}
	
	
	// Сила: 264
	// Здоровье: 256
	// Защита: 256
	// Сумма: 776

	// Сила: 20 (275%)
	// Здоровье: 33 (252%)
	// Защита: 21 (292%)
 
	echo '<div class="nfl p5 mb5 mt5 mlra">';
	echo '<table><td><img width="50" height="50" src="'.$item_id['lost_avatar'].'"></td>';
	echo '<td class="small" valign="top">';
	echo '<span class="ml5 small yellow1">'.$quality['image'].' '.$quality['name'].', '.$item_new.'</span><br/>';
	echo '<span class="ml5 small yellow1">'.$quality['image'].' '.$item_id['lost_name'].'</span><br/>';
	echo '<span class="ml5 small yellow1">'.$quality['image'].' '.name_item_mesto($item_id['lost_mesto']).'</span>';
	echo '</td></table><div class="hr mb5"></div>';
	echo '<div class="small white">';
	echo '<img src="/images/icons/strlen.png"> <span>Сила: </span><span class="yellow1">'.$genaration_params['strlen'].' <span class="ccc">('.$genaration_params['strlen_pr'].'%)</span></span><br/>';
	echo '<img src="/images/icons/heatpoints.png"> <span>Здоровье: </span><span class="yellow1">'.$genaration_params['heatpoints'].' <span class="ccc">('.$genaration_params['heatpoints_pr'].'%)</span></span><br/>';
	echo '<img src="/images/icons/protection.png"> <span>Защита: </span><span class="yellow1">'.$genaration_params['protection'].' <span class="ccc">('.$genaration_params['protection_pr'].'%)</span></span><br/>';
	echo '<img src="/images/icons/1.gif"> <span>Общая сумма: </span><span class="yellow1">'.$genaration_params['summa'].'</span>';
	echo '<div class="hr mt5 mb5"></div>';
	echo '- <span>Чары: '.(($enchants) ? $enchants['image'].'<span class="moderator">+'.$enchants['params'].' </span>'.$enchants['name'].'' : '<span class="gray1">не установлено</span>').'</span><br/>';
	echo '- <span>Сравнение: <span class="moderator">'.$item_id['lost_comparison'].'</span> ур. (+'.(($item_id['lost_comparison'] > 0) ? $item_id['lost_comparison'] * 5 : '0').'%)</span>';
	echo '<div class="hr mt5 mb5"></div>';
	echo '- <span>Владелец: </span>'.ikonka_user($owner['lost_race'], ((!empty($online[$item_id['lost_user']]))? 'online' : 'offline')).' <a class="yellow1" href="/user?id='.$item_id['lost_user'].'">'.$owner['lost_login'].'</a>';
	echo '<div class="hr mt5 mb5"></div>';
	echo '</div>';
	
		if ($item_id['lost_user'] == $user['lost_id']) {
		echo '<div class="cntr mt5 small p5">';
		echo ($item_id['lost_bag'] == 1 OR $item_id['lost_bag'] == 0) ? '<a class="button w70" href="/item?id='.$id.'&'.(($item_id['lost_bag'] == 0) ? 'go=wear">Надеть' : 'go=shoot">В рюкзак').'</a><br/>' : '';
		echo ($item_id['lost_bag'] == 1) ? '<a class="button w70 mt5" href="/item/enchants?go=upgrade&id='.$id.'">Улучшить у чародея</a><br/>' : '';
		echo ($item_id['lost_bag'] == 1 AND $item_id['lost_comparison'] < 20) ? '<a class="button w70 mt5" href="/item/comparison?go=upgrade&id='.$id.'">Сравнение</a><br/>' : '';
		echo ($item_id['lost_bag'] == 0) ? '<a class="button w70 mt5" href="/item?id='.$id.'&go=delete">Продать за <img src="/images/icons/cristall.png">'.((int)(($genaration_params['summa'] / 100) * 50)).'</a><br/>' : '';
		echo ($item_id['lost_bag'] == 0 AND $item_id['lost_quality'] >= 3) ? '<a class="button w70 mt5" href="/item?id='.$id.'&go=auction">На аукцион</a><br/>' : '';
		
		if ($item_id['lost_bag'] == 3) {
			echo '<a class="button w70" href="/item?id='.$id.'&go=shot_auction">Снять с аукциона</a>';
		}
		echo '</div>';
		}
	
echo '</div>';
require_once './element_include/element_foot_user_true.php';
?>