Файл: minichat_by_KoT/minichat_by_KoT/backpack.php
Строк: 64
<?php
##########################################
# ~ Разработка отдельных модулей ~~~~~~~ #
# ~ и написание скриптов на php (c)KoT ~ #
# ~ ICQ: 7675072 ~~~~~~~~~~~~~~~~~~~~~~~ #
# ~ Site: 4atlove.ru ~~~~~~~~~~~~~~~~~~~ #
# ~ E-mail: notefree@bk.ru ~~~~~~~~~~~~~ #
##########################################
require 'sid.php';
header("Cache-Control: no-cache");
header('Content-Type:text/html; charset=UTF-8');
require 'config.php';
$link = connect_db();
list($row, $id, $ps) = check_login($link);
include 'head.php';
whorm(0, 'backpack');
echo $div1 . '<b>Рюкзак</b>' . $div5;
if (isset($_GET['dress'])) {
if (!ctype_digit($_GET['i'])) {
header('Location: index.php?isset=403');
die();
}
$i = abs(intval($_GET['i']));
$who = mysql_fetch_array(mysql_query("SELECT `id`, `type` FROM `invent` WHERE `id` = '$i' AND `uid` = '$id' AND `second` = '0'"));
if ($who[1] == 'trud') {
header('Location: backpack.php?err');
die();
}
$err_1 = mysql_query("SELECT `id` FROM `invent` WHERE `id` = '$i' AND `uid` = '$id' AND `second` = '0'");
$err_2 = mysql_query("SELECT `id` FROM `invent` WHERE `uid` = '$id' AND `type` = '".check($who[1])."' AND `suited` = '1'");
if (mysql_num_rows($err_1) == 0) {
echo $bad . 'Вы пытаетесь одеть несуществующую вещь!' . $div5;
} elseif (mysql_num_rows($err_2) != 0) {
echo $bad . 'Часть тела, на которую Вы пытаетесь одеть вещь, уже занята!' . $div5;
} else {
$sql = "UPDATE `invent` SET `suited` = '1' WHERE `id` = '$i' AND `uid` = '$id'";
if (mysql_query($sql)) {
header('Location: backpack.php?ok');
die();
} else {
header('Location: backpack.php?err');
die();
}
}
}
if (isset($_GET['remove'])) {
if (!ctype_digit($_GET['i'])) {
header('Location: index.php?isset=403');
die();
}
$i = abs(intval($_GET['i']));
$who = mysql_fetch_array(mysql_query("SELECT `id`, `type` FROM `invent` WHERE `id` = '$i' AND `uid` = '$id' AND `second` = '0'"));
if ($who[1] == 'trud') {
header('Location: backpack.php?err');
die();
}
$err_1 = mysql_query("SELECT `id` FROM `invent` WHERE `id` = '$i' AND `uid` = '$id' AND `second` = '0'");
$err_2 = mysql_query("SELECT `id` FROM `invent` WHERE `uid` = '$id' AND `type` = '".check($who[1])."' AND `suited` = '1'");
if (mysql_num_rows($err_1) == 0) {
echo $bad . 'Вы пытаетесь снять несуществующую вещь!' . $div5;
} elseif (mysql_num_rows($err_2) == 0) {
echo $bad . 'Эта часть тела пуста!' . $div5;
} else {
$sql = "UPDATE `invent` SET `suited` = '0' WHERE `id` = '$i' AND `uid` = '$id'";
if (mysql_query($sql)) {
header('Location: backpack.php?ok');
die();
} else {
header('Location: backpack.php?err');
die();
}
}
}
if (isset($_GET['ok'])) {
echo $good . 'Операция успешно завершена!' . $div5;
}
if (isset($_GET['err'])) {
echo $bad . 'Непредвиденная ошибка!' . $div5;
}
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$start = ($page - 1) * 5;
$all = mysql_result(mysql_query("SELECT count(*) FROM `invent` WHERE `uid` = '$id' AND `second` = '0' AND `type` != 'staff'"), 0);
$vse = $all;
$all = ceil($all/5);
$all = $all > 5 ? 5 : $all;
$things = mysql_query("SELECT * FROM `invent` WHERE `uid` = '$id' AND `second` = '0' AND `type` != 'staff' ORDER BY `id` DESC LIMIT ".abs(intval($start)).", 5");
echo $other;
if (mysql_affected_rows() != 0) {
while($a = mysql_fetch_assoc($things)) {
if ($a['suited'] == 0) {
$suited = '| [<a href="backpack.php?dress&i='.$a['id'].'">Одеть</a>]';
} elseif ($a['suited'] == 1) {
$suited = '| [<a href="backpack.php?remove&i='.$a['id'].'">Снять</a>]';
}
if ($a['type'] == 'pushka') {
$type = 'Оружие';
$suited = $suited;
} elseif ($a['type'] == 'bron') {
$type = 'Броня';
$suited = $suited;
} elseif ($a['type'] == 'trud') {
$type = 'Орудие труда';
$suited = '';
}
if ($a['master'] != 0) {
$masters = ' улучшено + ' . $a['master'];
}
echo '<b>' . $a['name'] . '</b> ' . $suited . $masters . '<br/>
(' . $type . ')<br/>';
}
} else {
echo $bad . 'Рюкзак пуст...' . $div5;
}
echo '<hr/>Вещей в рюкзаке: <b>' . $vse . '</b><br/>';
echo '<hr/>';
for($i = 1; $i <= $all; $i++)
{
echo $pr=(($i == 1 || $i == $all || abs($i-$page) < 2) ? ($i == $page ? " [$i] " : ' <b><a href="backpack.php?page='.$i.'">'.$i.'</a></b>') : (($pr == ' ... ' || $pr == '') ? '' : ' ... '));
}
echo $div5;
echo $div3 . '
<a href="my.php?'.$ref.'"><b>Личный кабинет</b></a><br/>
<a href="menu.php?'.$ref.'"><b>В меню<b></a>' . $div5;
include 'foot.php';
?>