Файл: _modules/inv/objects/equip/index.php
Строк: 37
<?php
# mark core v1.0
# author Drk in
# date 24.10.19
# core
require_once ( $_SERVER['DOCUMENT_ROOT']."/_core/system.php" );
# user
system::access(true);
$id = isset( $_GET['id'] ) ? system::abs($_GET['id']): 0;
if (cache_inv::ch($id) == false)system::header('/inv/objects','Ошибка, предмет не найден');
$inv = cache_inv::check($id);
if (cache_itm::ch($inv['thing']) == false)system::header('/inv/objects','Ошибка, предмет не найден');
$itm = cache_itm::check($inv['thing']);
if ($user['id'] != $inv['user'])system::header('/inv/objects','Ошибка, предмет не найден');
# Аптечки и Еда
if ($inv['cat'] == 5 || $inv['cat'] == 8 ):
if ($itm['hp'] + $user['hp'] < $user['hp_max']): $_hp = $itm['hp'] + $user['hp']; else: $_hp = $user['hp_max']; endif;
if ($itm['eat'] + $user['eat'] < $user['hp_max']): $_eat = $itm['eat'] + $user['eat']; else: $_eat = $user['eat_max']; endif;
if ($itm['vit'] + $user['vit'] < $user['vit_max']): $_vit = $itm['vit'] + $user['vit']; else: $_vit = $user['vit_max']; endif;
$_rad = (-1*($itm['rad']));
if ($user['rad'] - $_rad < 0):$_rad = 0; else: $_rad = $user['rad'] - $_rad; endif;
if ($inv['cn'] > 1):
DB :: $dbh -> query("UPDATE user SET hp = ?, eat = ?, rad = ?, vit = ? WHERE id = ? LIMIT 1;",array($_hp,$_eat,$_rad,$_vit,$user['id']));
DB :: $dbh -> query("UPDATE inv SET cn = cn -1 WHERE id = ? LIMIT 1;",array($id));
cache_inv::save($id);
else:
DB :: $dbh -> query("UPDATE user SET hp = ?, eat = ?, rad = ?, vit = ? WHERE id = ? LIMIT 1;",array($_hp,$_eat,$_rad,$_vit,$user['id']));
DB :: $dbh -> query("DELETE FROM inv WHERE id = ? LIMIT 1;",array($id));
@unlink(cache."_inv/{$id}.data");
endif;
cache_user::save($user['id']);
cache_size::save($user['id'],$user['lvl_inv']);
system::header('/inv/objects','Успешно использовали '.($inv['cat'] == 5 ? 'аптечку':system::check($itm['name'])));
else:
system::header('/inv/objects','Ошибка, предмет нельзя использовать');
endif;
?>