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

Размер файла: 5.76Kb
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
	
	require_once './element_function/element_function_item.php';
	$wear_item = users_wear_item($user['lost_id']);
	$shoot_item = users_shoot_item($user['lost_id']); // Массив с вещами в рюкзаке
	$count_item = count($shoot_item);

	//$a = create_item($user['lost_id'], $shoot_item, false, false, false, false, false, false, false, false, 5);
	//echo $a;
$title = 'Рюкзак ['.$count_item.' / 20]';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
	
	
	if ($go == 'market' AND !$id) {
		if (count($shoot_item) > 0) {
			$crist = 0;
			foreach($shoot_item as $item) {
			$item_id = cache_item($item);
			if ($item_id['lost_quality'] < 2) { 
				if (isset($wear_item[$item_id['lost_mesto']])) {
					$my_item = cache_item($wear_item[$item_id['lost_mesto']]);
					$wear = item_generation_params($my_item['lost_strlen'], $my_item['lost_heatpoints'], $my_item['lost_protection'], $my_item['lost_comparison']);
					$shoot = item_generation_params($item_id['lost_strlen'], $item_id['lost_heatpoints'], $item_id['lost_protection'], $item_id['lost_comparison']);
						if ($wear['summa'] > $shoot['summa']) {
							$summa_del = ((int)(($shoot['summa'] / 100) * 50));
							$crist = $crist + $summa_del;
							mysql_query("DELETE FROM `element_item` WHERE `lost_id` = '$item' LIMIT 1");
							unset($shoot_item[$item]);
						}
				}
			}
			}
			if ($crist > 0) {
				update_money_exp($user, 0, $crist, 0, 0);
				writecache('element_shoot_item_user_id'.$user['lost_id'], $shoot_item);
				header('Location: /bag');
				exit;
			}
		}
	}
	
	if ($go == 'market' AND $id) {
		$item = cache_item($id);
		if ($item['lost_user'] == $user['lost_id'] AND $item['lost_bag'] == 0) {
			$shoot = item_generation_params($item['lost_strlen'], $item['lost_heatpoints'], $item['lost_protection'], $item['lost_comparison']);
			$summa_del = ((int)(($shoot['summa'] / 100) * 50));
			mysql_query("DELETE FROM `element_item` WHERE `lost_id` = '$id' LIMIT 1");
			update_money_exp($user, 0, $summa_del, 0, 0);
			unset($shoot_item[$id]);
			writecache('element_shoot_item_user_id'.$user['lost_id'], $shoot_item);
			header('Location: /bag');
			exit;
		}
	}
	
	if ($go == 'wear' AND $id) {
		$item = cache_item($id);
		if ($item) {
			if ($item['lost_quality'] < 3 AND $item['lost_new'] == 0) {
				if (isset($_GET['ok'])) {
					wear_item($user, $item, $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="/bag?go=wear&id='.$id.'&ok">Да</a> <a class="button w30 ml2" href="/bag">Нет</a></div>';
				echo '</div>';
				}
			} else wear_item($user, $item, $shoot_item, $wear_item, '/bag', 0);
		}
	}

	echo '<div class="nfl p5 mb5 mt5 small mlra">';

	if ($count_item == 0) {
		echo '<div class="white cntr">В вашем рюкзаке, вещей не найдено</div>';
	} else {
		$as = 0;
		echo '<table>';
		foreach($shoot_item as $item) {
		$item_id = cache_item($item);
		$quality = quality_item_name($item_id['lost_quality']);
		$item_new = ($item_id['lost_new'] == 0) ? 'Новый' : '<span class="ccc">Личный</span>';
		$shoot = item_generation_params($item_id['lost_strlen'], $item_id['lost_heatpoints'], $item_id['lost_protection'], $item_id['lost_comparison']);
		$bla = item_params_type($item_id['lost_mesto']);
		$enchants = item_enchants_quality($item_id['lost_enchants'], $bla[1]);
		
		if (isset($wear_item[$item_id['lost_mesto']])) {
			$my_item = cache_item($wear_item[$item_id['lost_mesto']]);
			$wear = item_generation_params($my_item['lost_strlen'], $my_item['lost_heatpoints'], $my_item['lost_protection'], $my_item['lost_comparison']);
			
			if ($wear['summa'] > $shoot['summa']) $result = ', <span class="red">Хуже: -'.($wear['summa'] - $shoot['summa']).'</span>';
			else if ($wear['summa'] < $shoot['summa']) $result = ', <span class="lngreen">Лучше: +'.($shoot['summa'] - $wear['summa']).'</span>';
			else $result = '';
		} else $result = ', <span class="lngreen">Лучше: +'.($shoot['summa']).'</span>';
		
		
			echo '<tr><td><img width="50" height="50" src="'.$item_id['lost_avatar'].'"></td>';
			echo '<td class="small" valign="top">';
			echo '<span class="ml2 small">'.$quality['image'].' <a class="yellow1" href="/item?id='.$item.'">'.$item_id['lost_name'].'</a> '.(($enchants) ? $enchants['image'] : '').'</span><br/>';
			echo '<span class="ml2 small white">'.$item_new.$result.'</span><br/>';
			echo '<span class="ml2 small white"><a class="moderator" href="/bag?go=wear&id='.$item.'">[Надеть]</a></span>';
				if ($item_id['lost_quality'] < 2) {
					if ($wear['summa'] > $shoot['summa']) {
						$summa_del = ((int)(($shoot['summa'] / 100) * 50));
						echo ' <a class="moderator" href="/bag?go=market&id='.$item.'">[Продать за <img src="/images/icons/cristall.png">'.$summa_del.']</a>';
						$as = $as + $summa_del;
					}
				}
			echo '</tr>';
		}
		if ($as > 0) echo '<div class="p5 cntr"><a class="moderator" href="/bag?go=market">Продать ненужные вещи за <img src="/images/icons/cristall.png">'.$as.'</a></div>';
		echo '</table>';
		if ($as > 0) echo '<div class="p5 cntr"><a class="moderator" href="/bag?go=market">Продать ненужные вещи за <img src="/images/icons/cristall.png">'.$as.'</a></div>';
	}

echo '</div>';
require_once './element_include/element_foot_user_true.php';
?>