Файл: public_html/box.php
Строк: 103
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
require_once './element_function/element_function_item.php';
define('START_PRICE', 20);
$wear_item = users_wear_item($user['lost_id']);
$shoot_item = users_shoot_item($user['lost_id'], 'box');
$count_item = count($shoot_item);
if (empty($user['box']))
{
$user['box'] = 0;
}
$title = 'Сундук ['.$count_item.' / '.$user['box'].']';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
if ($go == 'bag' AND $id && sizeof(users_shoot_item($user['lost_id'])) < 20)
{
$item = cache_item($id);
if ($item['lost_user'] == $user['lost_id'] AND isset($shoot_item[$id]))
{
mysql_query("UPDATE `element_item` SET `lost_bag`='0' WHERE `lost_id` = '$id' LIMIT 1");
unset($shoot_item[$id]);
writecache('element_shoot_box_item_user_id'.$user['lost_id'], $shoot_item);
$box_i = users_shoot_item($user['lost_id']);
$box_i[$id] = $id;
writecache('element_shoot_item_user_id'.$user['lost_id'], $box_i);
header('Location: /box.php');
exit;
}
}
if ($go == 'up_box' && $user['box'] < 100)
{
if ($user['box'] == 0)
{
$price = 20;
$box_incl = 20;
}
else
{
$price = START_PRICE;
for ($i = 21; $i <= ($user['box'] + 1); $i++)
{
$price *= 2;
}
$box_incl = 1;
}
if ($user['lost_money_gold'] >= $price)
{
$user['box'] += $box_incl;
mysql_query("UPDATE `element_user` SET `box`=`box`+'{$box_incl}' WHERE `lost_id`='{$user['lost_id']}' LIMIT 1");
update_money_exp($user, 0, 0, 0, -$price);
header('Location: /box.php');
exit;
}
else
{
echo '<div class="nfl p5 mb5 mt5 small mlra">Не хвататет золота</div>';
}
}
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/>';
if (sizeof(users_shoot_item($user['lost_id'])) < 20)
echo '<span class="ml2 small white"><a class="moderator" href="/box.php?go=bag&id='.$item.'">[В рюкзак]</a></span>';
echo '</tr>';
}
echo '</table>';
}
echo '</div>';
echo '<div class="nfl p5 mb5 mt5 cntr small mlra">';
echo '<div class="small ml5 lngreen">Вместимость сундука '.$user['box'].' предметов</div>';
if ($user['box'] == 0)
{
echo '<a class="button w60 mt5 mb5" href="?go=up_box">Купить сундук (+20) за <img src="/images/icons/gold.png">20</a>';
}
else
{
if ($user['box'] < 100)
{
$user['box'] += 1;
$s = START_PRICE;
for ($i = 21; $i <= $user['box']; $i++)
{
$s *= 2;
}
echo '<a class="button w60 mt5 mb5" href="?go=up_box">Улучшить (+1) за <img src="/images/icons/gold.png">'.$s.'</a>';
}
else
{
}
}
echo '</div>';
require_once './element_include/element_foot_user_true.php';
?>