battles/hostel_room.php
2018-01-28 18:40:49 +02:00

175 lines
6.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
session_start();
if(!isset($_SESSION['uid'])) { header('Location: index.php'); die(); }
include('config.php');
include('functions.php');
$d = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `setsale` = 0"));
$in = mysql_fetch_array(mysql_query('SELECT COUNT(*) AS `cnt` FROM `inventory` WHERE `owner` = "-101'.$user['id'].'"'));
$hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "'.$user['id'].'" LIMIT 1'));
$base = array(1 => 15, 2 => 30, 3 => 50, 4 => 100);
$vips = array(1 => 0.15, 2 => 0.30, 3 => 0.45);
if($user['vip'] > 0 && $user['vip_time'] > time()) {
$count = $base[$hostel['type']];
$count += floor($base[$hostel['type']]*$vips[$user['vip']]);
} else {
$count = $base[$hostel['type']];
}
if($_GET['search']) {
$r = show_itm_hostel($user['id'], (int)$_GET['otdel'], (int)$_GET['place']);
} else {
$r = '<tr><td width="100%" align="center" class="even" style="text-align: center;"><b><center>Поиск ...</center></b></td></tr>';
}
if($_GET['set'] && $_GET['set'] == 1) {
$it = mysql_fetch_array(mysql_query('SELECT `id`, `owner` FROM `inventory` WHERE `id` = "'.(int)$_GET['itm'].'" LIMIT 1'));
if(isset($it['id'])) {
if($it['owner'] == $user['id']) {
if($in['cnt'] < $count) {
mysql_query('UPDATE `inventory` SET `owner` = "-101'.$user['id'].'" WHERE `id` = "'.$it['id'].'" LIMIT 1');
$in['cnt']++;
} else {
$error = 'Не хватает места ...';
}
} elseif($it['owner'] == '-101'.$user['id']) {
mysql_query('UPDATE `inventory` SET `owner` = "'.$user['id'].'" WHERE `id` = "'.$it['id'].'" LIMIT 1');
$in['cnt']--;
}
}
unset($it);
header('Location: hostel_room.php?search=1&otdel='.$_GET['otdel'].'&place='.$_GET['place']);
}
if($_GET['search']) {
$r = show_itm_hostel($user['id'], (int)$_GET['otdel'], (int)$_GET['place']);
}
#######
$w = (270*$d['mass']/get_meshok()); $w_a = 270-$w;
$h = (270*$in['cnt']/$count); $h_a = 270-$h;
#######
if($_GET['go_back'] == 1) {
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 660, `online`.`room` = 660 WHERE `users`.`id` = "'.$user['id'].'" AND `online`.`id` = "'.$user['id'].'"');
header('Location: hostel.php');
}
?>
<!doctype html>
<html>
<head>
<title>404</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="ru" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/ajaxLoad.js"></script>
<link rel="stylesheet" type="text/css" href="css/hostel.css" />
</head>
<body>
<div class="contentContainer" id="hostelContainer">
<div id="systemMsg" class="system-msg"></div><div class="buttonContainer">
<input type="button" class="btns" value="Обновить" onclick="location.href='hostel_room.php';" />
<input type="button" class="btns button-route" value="Спуститься" onclick="location.href='?go_back=1';" />
<h1>Комнатуха</h1>
</div>
<style type="text/css">
.hides {
display: none;
}
#hstInventory td.item {
width: 85%;
}
#hstInventory td.links {
text-align:center;
vertical-align:middle;
width:117px;
}
#hstInventory td.links span {
display: block;
}
#hstInventory td.original span.pk-current{
display:none;
}
#hstInventory td.moved {
font-weight: bold;
}
#hstInventory td.odd {
background-color: #c7c7c7;
}
#hstInventory td.even {
background-color: #d5d5d5;
}
label{
font-weight: bold;
margin-right:15px;
}
</style>
<script>
function hide_this(id) {
var node = document.getElementById(id);
if(node) {
node.style.display = 'none';
};
}
</script>
<div style="overflow: hidden;">
<fieldset id="hstInventoryA" style="width: 377px; float: left; text-align: center;">
<legend>Фильтр инвентаря</legend>
<div style="height: 53px">
<form method="GET">
<input type="radio" class="radio" id="hstF1" name="place" value="2" /><label for="hstF1">мешок</label>
<input type="radio" class="radio" id="hstF2" name="place" value="1" /><label for="hstF2">сундук</label>
<div style="height: 5px;overflow: hidden;"></div>
<select name="otdel">
<option value="-1">&nbsp;</option>
<optgroup label="Оружие">
<option value="1">кастеты,ножи</option>
<option value="11">топоры</option>
<option value="12">дубины,булавы</option>
<option value="13">мечи</option>
</optgroup>
<optgroup label="Одежда">
<option value="2">сапоги</option>
<option value="21">перчатки</option>
<option value="22">легкая броня</option>
<option value="23">тяжелая броня</option>
<option value="24">шлемы</option>
</optgroup>
<optgroup label="Щиты">
<option value="3">щиты</option>
</optgroup>
<optgroup label="Ювелирные товары">
<option value="4">серьги</option>
<option value="41">ожерелья</option>
<option value="42">кольца</option>
</optgroup>
<optgroup label="Заклинания">
<option value="5">нейтральные</option>
<option value="51">боевые и защитные</option>
</optgroup>
<optgroup label="Амуниция">
<option value="6">амуниция</option>
</optgroup>
</select>&nbsp;
<input type="submit" class="button" style="margin-right: 20px;" value="Поиск" name="search" />
</form>
</div>
</fieldset>
<fieldset id="hstInventoryB"><legend>Состояние</legend>
<div style="height: 53px">
<div class="progressBar" style='height:14px'><img title="Мешок за спиной" src="/i/bag.gif" height="14px"><img title="Мешок за спиной" src="/i/660000.gif" style="width: <?=$w;?>px; height: 14px;"><img title="Мешок за спиной" src="/i/1silver.gif" style=" width: <?=$w_a;?>px; height:14px"><tt style="font-size:13px"> <?=$d['mass'];?>/<?=get_meshok()?></tt></div><div class="progressBar" style='height:14px'><img title="Заполнение сундука" src="/i/chest.gif" height="14px"><img title="Заполнение сундука" src="/i/1blue.gif" style=" width: <?=$h;?>px; height:14px"><img title="Заполнение сундука" src="/i/1silver.gif" style=" width: <?=$h_a;?>px; height:14px"><tt style="font-size:13px"> <?=$in['cnt'];?>/<?=$count;?></tt></div></div>
</fieldset>
</div>
<div id="hstInventory" style="width: 100%; background-color: #a5a5a5;">
<?=$r;?>
</div>
<center><? if($error != '') { echo '<br /><b style=\'color: Red;\'>'.$error.'</b>'; } ?></center>
</body>
</html>