Файл: public_html/element_auctions.php
Строк: 217
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
require_once './element_function/element_function_item.php';
$title = 'Аукцион';
if (readcache('element_user_mesto'.$user['lost_id']) != $title) writecache('element_user_mesto'.$user['lost_id'], $title);
$search_sql = '';
if ($go == 'search')
{
$search = $_POST;
if ( ! isset($_POST['set_q'], $_POST['set']))
{
$search = readcache('auctions_search_'.$user['lost_id']);
if ( ! is_array($search))
{
$search = array();
}
}
if ( ! empty($search['set_q']) && in_array($search['set_q'], array(3, 4, 5)))
{
$search_sql = "WHERE `lost_quality`='{$search['set_q']}'";
}
if ( ! empty($search['set']) && in_array($search['set'], $array_type))
{
$search_sql = (strlen($search_sql) ? $search_sql." AND " : "WHERE ")."`lost_mesto`='{$search['set']}'";
}
if (strlen($search_sql))
{
writecache('auctions_search_'.$user['lost_id'], $search);
}
}
$count = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_auction` {$search_sql} ORDER BY `lost_time` DESC"), 0);
$wear_item = users_wear_item($user['lost_id']);
$shoot_item = users_shoot_item($user['lost_id']);
if ($user['lost_level'] <5 ) {
$title = 'Доступ закрыт';
$error1 = '<span class="small">Аукцион доступен только с 5-ого уровня</span>';
require_once 'element_error_page.php';
exit;
}
if ($go == 'cancel' AND $id) {
$item = cache_item($id);
if ($user['lost_id'] != $item['lost_user'] && $item['lost_bag'] == 3)
{
$mshoot_item = users_shoot_item($item['lost_user']);
if (count($mshoot_item) <= 20)
{
require_once './element_function/element_function_mail.php';
$item['lost_bag'] = 0;
mysql_query("UPDATE `element_item` SET `lost_bag` = '0' WHERE `lost_id` = '$item[lost_id]' LIMIT 1");
mysql_query("DELETE FROM `element_auction` WHERE `lost_id` = '$item[lost_id]' LIMIT 1");
$mshoot_item[$item['lost_id']] = $item['lost_id'];
$mu = cache_user($item['lost_user']);
$profile_other = explode(' ', $mu['lost_other']);
$profile_other[2] = $profile_other[2] + 1;
$mu['lost_other'] = implode(' ', $profile_other);
mysql_query("INSERT INTO `element_mail` SET `lost_out` = '0',`lost_in` = '$mu[lost_id]',`lost_sub_text` = 'Вещь сняли с аукциона',`lost_text` = 'Модераторы сняли одну из Ваших <a href="/item?id={$item['lost_id']}">вещей</a> с аукциона',`lost_user_out` = '0',`lost_user_in` = '$mu[lost_id]',`lost_time` = '".time()."',`lost_system` = 'Аукцион',`lost_new` = '1'");
$count_in = Cache_Count_Message($mu['lost_id']);
if (!empty($count_in['all'])) $count_in['all']++;
if (!empty($count_in['in'])) $count_in['in']++;
if (!empty($count_in['new'])) $count_in['new']++;
writecache('element_count_message'.$mu['lost_id'], $count_in);
writecache('element_users_id_'.$mu['lost_id'], $mu);
writecache('element_shoot_item_user_id'.$item['lost_user'], $mshoot_item);
header('Location: ?');
die;
}
else
{
echo 'У пацана в рюкзаке нет места<br/>';
}
}
else
{
AuctionItemCancel($user['lost_id'], $shoot_item, $item, 'bag');
}
}
$title = 'Аукцион вещей';
if ( ! empty($_POST['set_q']) && in_array($_POST['set_q'], array(3, 4, 5)))
{
$_qual = quality_item_name($_POST['set_q']);
$title .= ", качество {$_qual['name']}";
}
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
if ($go == 'shop' AND $id) {
require_once './element_function/element_function_mail.php';
$item = cache_item($id);
if (isset($_GET['ok'])) {
AuctionItemShop($user, $shoot_item, $item, '/auctions', true, '/', '/');
} else AuctionItemShop($user, $shoot_item, $item, '/', false, '/auctions?go=shop&id='.$id.'&ok', '/auctions');
}
echo '<div class="nfl p5 mb5 small mt5 mlra">';
echo '<div class="game-master cntr">Аукцион предназначен для торговли снаряжением<br/>Торговать можно только вещами следующего качества: <span class="yellow1">Дары Богов, Трофейные, Уникальные, Эпические и Легендарные</span></div>';
echo '<div class="hr mt5 mb5"></div>';
if ($count > 0) {
require_once './element_function/element_function_pagination.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$pagination = pagination(10, $page, $count);
$query = mysql_query("SELECT * FROM `element_auction` {$search_sql} ORDER BY `lost_time` DESC LIMIT $pagination[start], $pagination[num]");
while ($myrrow = mysql_fetch_array($query)) {
$item = cache_item($myrrow['lost_id']);
$bla = item_params_type($item['lost_mesto']);
$quality = quality_item_name($item['lost_quality']);
$enchants = item_enchants_quality($item['lost_enchants'], $bla[1]);
$shoot = item_generation_params($item['lost_strlen'], $item['lost_heatpoints'], $item['lost_protection'], $item['lost_comparison']);
if (isset($wear_item[$item['lost_mesto']])) {
$my_item = cache_item($wear_item[$item['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 '<div class="mb2">
<table>
<td>
<img width="50" height="50" src="'.$item['lost_avatar'].'">
</td>
<td class="small" valign="top">
<span class="lngreen ml2">'.$quality['image'].' <a class="yellow1 small" href="/item?id='.$item['lost_id'].'">'.$item['lost_name'].'</a> '.$item['lost_comparison'].' ур</span><br/>';
echo '<span class="ml2 yellow1">'.(($enchants) ? '<span class="moderator">'.$enchants['image'].'+'.$enchants['params'].'</span> '.$enchants['name'].', </span>' : ''). $result.'</span><br/>';
echo '<span class="ml2 yellow1">'.(($user['lost_id'] == $myrrow['lost_user']) ? '- Мой лот <a href="/auctions?go=cancel&id='.$myrrow['lost_id'].'">[Отменить]</a>' : '<a href="/auctions?go=shop&id='.$myrrow['lost_id'].'">[Купить за <img src="/images/icons/gold.png">'.$myrrow['lost_gold'].']</a>').'</span>';
if ($user['lost_privilege'] > 0)
{
echo ' <span class="ml2 yellow1"><a href="/auctions?go=cancel&id='.$myrrow['lost_id'].'">[Отменить]</a></span>';
}
echo '</td>
</table>
</div>';
}
echo '<div>'.pagination_echo($pagination['page'],$pagination['total'],'/auctions/?'.($go == 'search' ? 'go=search&' : '').'page=').'</div>';
} else echo '<div class="cntr ccc">На аукционе нет вещей</div>';
echo '<div class="hr mt5 mb5"></div>';
echo '<form class="cntr" method="post" action="/auctions?go=search">';
echo '<label class="bl mb5 ccc">Качество:<br>
<select class="fdark mb10 w60" name="set_q">
<option value="" selected>Любое</option>
<option value="3">Дары Богов</option>
<option value="4">Трофейное</option>
<option value="5">Уникальное</option>
</select>
</label>';
echo '<label class="bl mb5 ccc">Слот:<br>
<select class="fdark mb10 w60" name="set">';
foreach($array_type as $key => $value) {
echo '<option value="'.$value.'">'.name_item_mesto($value).'</option>';
}
echo '</select>
</label>';
echo '<span class="button w40 mt5"><input type="submit" class="ttl" value="Поиск"/></span><br/><br/>';
echo '</form>';
echo '</div>';
require_once './element_include/element_foot_user_true.php';
?>