Файл: DARK WARS/dark_war/weapon_shop/sell.php
Строк: 18
<?php
include_once '../start.php';
$doc = new document();
$doc->title('Продажа');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$doc->err('Ошибка, не выбрано оружие');
exit();
}
$id = (int)$_GET['id'];
$q = mysql_query("SELECT * FROM `dark_war_wshop_u` WHERE id='$id' AND `id_player` = '$player->id' LIMIT 1");
if (!mysql_num_rows($q)) {
$doc->err('У вас нет такого артефакиа');
exit();
}
$ar = mysql_fetch_assoc($q);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `dark_war_wshop_u` WHERE `id` = '$id' AND `active` = '1'"),0)>0) {
$doc->err('Данная вещь установлена, снимите ее');
exit();
}
if (isset($_GET['yes'])) {
$gold = ceil($ar['gold'] * 43 / 100);
$silver = ceil($ar['silver'] * 43 / 100);
mysql_query("UPDATE `dark_war_users` SET `gold` = `gold` + '$gold', `silver` = `silver` + '$silver' WHERE `id` = '{$player->id}'");
mysql_query("DELETE FROM `dark_war_wshop_u` WHERE `id` = '$id' AND `id_player` = '{$player->id}' LIMIT 1");
$doc->msg('Вы продали артефакт');
}
$img = "<img src='/dark_war/all_img/weapon_shop/$ar[type]/$ar[img].png' alt='!' />";
$title = "Вы продаете товар";
$request[] = "Ваш доход с продажы составит";
$request[] = "Золото: + " . ceil($ar['gold'] * 43 / 100);
$request[] = "Серебро: + " . ceil($ar['silver'] * 43 / 100);
$action[] = array('link' => "sell.php?id=$id&yes".(isset($_GET['page'])?'&page='.$_GET['page'].'' : '')."", 'name' => 'Продать');
$list = array('img' => $img, 'title' => $title, 'request' => $request, 'action' => $action);
$doc->assign('list', $list);
$doc->display('view_info.tpl');
$doc->ret("my_artifacts.php".(isset($_GET['page'])?'?page='.$_GET['page'].'' : '')."", 'Мои артефакты');
$doc->ret("my_info.php?id=$id".(isset($_GET['page'])?'?page='.$_GET['page'].'' : '')."", 'Информация');
?>