Файл: public_html/equipment.php
Строк: 78
<?php
include ('./system/system.php');
$title = 'Снаряжение';
include ('./system/head.php');
if(!$user) {
header('location: /index.php');
exit();
}
$id = _string(_num($_GET['id']));
if($id) {
$item = mysql_query('SELECT * FROM `equipment` WHERE `id` = "'.$id.'" && `id_user` = "'.$user['id'].'"');
$item = mysql_fetch_array($item);
$status = mysql_result(mysql_query('SELECT COUNT(*) FROM `equipment` WHERE `id_user` = "'.$user['id'].'" AND `type` = "'.$item['type'].'" AND `status` != "0"'),0);
$status_vb = mysql_result(mysql_query('SELECT COUNT(*) FROM `equipment` WHERE `id_user` = "'.$user['id'].'" AND `type` = "'.$item['type'].'" AND `status` != "0" && `id` = "'.$item['id'].'"'),0);
if(!$item) {
header('location: ?');
exit();
}
if(isset($_GET['od'])) {
if($status >= 1 && $item['type'] != Оружие) {
echo '<div class="block small red center">Вещь такого типа уже одета!</div>';
echo '<a href="?id='.$item['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include ('./system/foot.php');
exit();
}
if($status >= 3 && $item['type'] == Оружие) {
echo '<div class="block small red center">Вещь такого типа уже одета!</div>';
echo '<a href="?id='.$item['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include ('./system/foot.php');
exit();
}
mysql_query("update `equipment` set `status` = 1 where `id` = '".$item['id']."'");
mysql_query("update `users` set `strength` = `strength` + '".$item['strength']."', `max_energy` = `max_energy` + '".$item['max_energy']."', `max_health` = `max_health` + '".$item['max_health']."', `armor` = `armor` + '".$item['armor']."' where `id` = '".$user['id']."'");
header('location: ?id='.$item['id'].'');
exit();
}
if(isset($_GET['sn'])) {
mysql_query("update `equipment` set `status` = 0 where `id` = '".$item['id']."'");
mysql_query("update `users` set `strength` = `strength` - '".$item['strength']."', `max_health` = `max_health` - '".$item['max_health']."', `max_energy` = `max_energy` - '".$item['max_energy']."', `armor` = `armor` - '".$item['armor']."' where `id` = '".$user['id']."'");
header('location: ?id='.$item['id'].'');
exit();
}
if(isset($_GET['vb'])) {
if($status_vb == 0) {
mysql_query("update `equipment` set `id_user` = 0 where `id` = '".$item['id']."'");
header('location: ?');
exit();
}
}
echo '<div class="block">';
if($item['img']) {
echo '<img src="'.$item['img'].'"><br>';
}
echo ''.$item['name'].' ('.$item['type'].')<br> Параметры: '.$item['strength'].' <img src="/images/icons/strength.png"> '.$item['armor'].' <img src="/images/icons/armor.png"> '.$item['max_health'].' <img src="/images/icons/health.png"> '.$item['max_energy'].' <img src="/images/icons/energy.png">
</div>';
if($item['status'] == 0) {
echo '<a href="?id='.$item['id'].'&od" class="link"><img src="/images/icons/forward.png"> Надеть</a>';
echo '<a href="?id='.$item['id'].'&vb" class="link"><img src="/images/icons/forward.png"> Выбросить</a>';
} else {
echo '<a href="?id='.$item['id'].'&sn" class="link"><img src="/images/icons/forward.png"> Снять</a>';
}
include ('./system/foot.php');
exit();
}
$max = 10;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `equipment` WHERE `id_user` = '".$user['id']."'"),0);
$k_page = k_page($k_post,$max);
$page = page($k_page);
$start = $max*$page-$max;
$q = mysql_query("SELECT * FROM `equipment` WHERE `id_user` = '".$user['id']."' ORDER BY `id` DESC LIMIT $start, $max");
while($snar = mysql_fetch_assoc($q)) {
echo '<a href="?id='.$snar['id'].'" class="link"><img src="/images/icons/forward.png"> '.$snar['name'].'';
if($snar['status'] == 1) {
echo ' <font color="#30c030">(+)</font>';
}
echo '</a>';
}
if($k_post<1) {
echo '<div class="block small red center">Ничего нет!</div>';
}
if($k_page>1) echo str('?',$k_page,$page);
include ('./system/foot.php');
?>