Файл: pages/economy/item.php
Строк: 378
<?php
// Physical module map v50.6: public URL stays clean while code lives in /pages.
if (!defined('GAME_ROOT')) define('GAME_ROOT', dirname(__DIR__, 2));
chdir(GAME_ROOT);
if (PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/item.php'; $_SERVER['SCRIPT_NAME']='/item.php'; }
/* Обновление игры под PHP 8.4 / PDO и усиление безопасности: by Метриум (Стэлп) */
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
$id = _string(_num($_GET['id']));
$inv = db_query('SELECT * FROM `inv` WHERE `id` = "'.$id.'"');
$inv = db_fetch_array($inv);
if(!$inv) {
header('location: /');
exit;
}
// Улучшение звезд вещи только за звездную пыль — by Метриум (Стэлп).
if(isset($_POST['star_up']) && (int)$inv['user']===(int)$user['id']) { security_require_csrf();
$stars=(int)($inv['stars'] ?? 0); $costs=[0=>10,1=>25,2=>50,3=>100,4=>200];
if($stars<5){ $cost=$costs[$stars]; $sd=game_star_chest_state((int)$user['id']);
if((int)$sd['dust'] >= $cost){ $next=$stars+1; $inc=10*$next;
db_query("UPDATE `stars_dust_users` SET `dust`=`dust`-$cost WHERE `user`=".(int)$user['id']);
db_query("UPDATE `inv` SET `stars`=$next,`_str`=`_str`+$inc,`_vit`=`_vit`+$inc,`_agi`=`_agi`+$inc,`_def`=`_def`+$inc WHERE `id`=".(int)$inv['id']);
if((int)$inv['equip']===1) db_query("UPDATE `users` SET `str`=`str`+$inc,`vit`=`vit`+$inc,`agi`=`agi`+$inc,`def`=`def`+$inc WHERE `id`=".(int)$user['id']);
$_SESSION['news']='Звезда улучшена до '.$next.'. Потрачено '.$cost.' звездной пыли.';
} else $_SESSION['news']='Недостаточно звездной пыли: нужно '.$cost.'.';
}
header('Location: /item/'.(int)$inv['id'].'/'); exit;
}
$item = db_query('SELECT * FROM `items` WHERE `id` = "'.$inv['item'].'"');
$item = db_fetch_array($item);
$title = $item['name'];
include './system/h.php';
$ownedQuality=game_item_quality_from_owned($inv,$item);
$qinfo=game_item_quality_info($ownedQuality);
$all_bonus=(int)$qinfo['max_bonus'];
$quality=(string)$qinfo['name'];
$quality_color=(string)$qinfo['color'];
switch($item['w']) {
case 1:
$w = 'Голова';
break;
case 2:
$w = 'Плечи';
break;
case 3:
$w = 'Торс';
break;
case 4:
$w = 'Перчатки';
break;
case 5:
$w = 'Левая рука';
break;
case 6:
$w = 'Правая рука';
break;
case 7:
$w = 'Ноги';
break;
case 8:
$w = 'Обувь';
break;
}
?>
<div class="item-v34" style="--quality-border:<?=security_html((string)$qinfo['border'])?>">
<div class='title item-title-v34' style='color:<?=security_html($quality_color)?>'><?=security_html($title)?></div>
<div class='line'></div>
<div class='content'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/itemImage.php?id=<?=$item['id']?>&smith=<?=$inv['smith']?>' alt='*'/></td>
<td valign='top' style='padding-left: 5px;'><img src='/images/icon/quality/<?=$ownedQuality?>.png' alt="*"/> <span style="color:<?=security_html($quality_color)?>"><?=security_html($item['name'])?></span>, <?=$w?>
<br/>
<small><small>
<font color='<?=$quality_color?>'><small><?=$quality?> [<?=$inv['bonus']?>/<?=$all_bonus?>]</font><br/>
Мастерство: <img src='/images/icon/skill.png' alt='*'/>
<?php
if($user['skill'] < $item['skill']) {
?>
<font color='#c66'>
<?php
}
echo $item['skill'];
if($user['skill'] < $item['skill']) {
?>
</font>
<?php
}
?>
</small></small></td>
</tr></table>
</div>
<div class='line'></div>
<div class="content">
<?php
$equip_item = db_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
$equip_item = db_fetch_array($equip_item) ?: ['_str'=>0,'_vit'=>0,'_agi'=>0,'_def'=>0];
$diff = 0;
?>
<img src='/images/icon/str.png' alt='*'/> Сила: <font color="
<?php
if($inv['_str'] > $equip_item['_str']) {
$diff += $inv['_str'] - $equip_item['_str'];
?>#3c3<?php
}
else
{
?>#c66<?php
}
?>
"> <?=$inv['_str']?></font><br/>
<img src='/images/icon/vit.png' alt='*'/> Жизнь: <font color="
<?php
if($inv['_vit'] > $equip_item['_vit']) {
$diff += $inv['_vit'] - $equip_item['_vit'];
?>#3c3<?php
}
else
{
?>#c66<?php
}
?>
">
<?=$inv['_vit']?></font><br/>
<img src='/images/icon/agi.png' alt='*'/> Удача: <font color="
<?php
if($inv['_agi'] > $equip_item['_agi']) {
$diff += $inv['_agi'] - $equip_item['_agi'];
?>#3c3<?php
}
else
{
?>#c66<?php
}
?>
"><?=$inv['_agi']?></font><br/>
<img src='/images/icon/def.png' alt='*'/> Защита: <font color="
<?php
if($inv['_def'] > $equip_item['_def']) {
$diff += $inv['_def'] - $equip_item['_def'];
?>#3c3<?php
}
else
{
?>#c66<?php
}
?>"><?=$inv['_def']?></font><br/>
<?php
if($user['w_'.$item['w']] != 0) {
if($inv['_str'] > $equip_item['_str'] OR $inv['_vit'] > $equip_item['_vit'] OR $inv['_agi'] > $equip_item['_agi'] OR $inv['_def'] > $equip_item['_def']) {
?>
<img src='/images/icon/quest.png' alt='*'/> <font color='#3c3'>Лучше +<?=$diff?></font>
<?php
}
}
$smith = 0;
if($inv['smith'] > 0) {
$smith += 24;
}
if($inv['smith'] > 1) {
$smith += 28;
}
if($inv['smith'] > 2) {
$smith += 32;
}
if($inv['smith'] > 3) {
$smith += 36;
}
if($inv['smith'] > 4) {
$smith += 40;
}
if($inv['smith'] > 5) {
$smith += 44;
}
if($inv['smith'] > 6) {
$smith += 48;
}
if($inv['smith'] > 7) {
$smith += 52;
}
if($inv['smith'] > 8) {
$smith += 56;
}
if($inv['smith'] > 9) {
$smith += 60;
}
if($inv['smith'] > 10) {
$smith += 64;
}
if($inv['smith'] > 11) {
$smith += 68;
}
if($inv['smith'] > 12) {
$smith += 72;
}
if($inv['smith'] > 13) {
$smith += 76;
}
if($inv['smith'] > 14) {
$smith += 80;
}
if($inv['smith'] > 15) {
$smith += 84;
}
if($inv['smith'] > 16) {
$smith += 88;
}
if($inv['smith'] > 17) {
$smith += 92;
}
if($inv['smith'] > 18) {
$smith += 96;
}
if($inv['smith'] > 19) {
$smith += 100;
}
$bonus = 0;
if($inv['bonus'] > 0) {
}
if($inv['rune']) {
switch($inv['rune']) {
case 1:
$rune_stats = 75;
break;
case 2:
$rune_stats = 150;
break;
case 3:
$rune_stats = 250;
break;
case 4:
$rune_stats = 600;
break;
case 5:
$rune_stats = 1000;
break;
case 6:
$rune_stats = 2000;
break;
}
switch($item['w']) {
case 1:
$rune_stat = 'силы';
break;
case 2:
$rune_stat = 'жизни';
break;
case 3:
$rune_stat = 'жизни';
break;
case 4:
$rune_stat = 'удачи';
break;
case 5:
$rune_stat = 'силы';
break;
case 6:
$rune_stat = 'силы';
break;
case 7:
$rune_stat = 'брони';
break;
case 8:
$rune_stat = 'жизни';
break;
}
}
$bonus = 0;
switch($item['quality']) {
case 0:
$bonus = $inv['bonus'] * 0;
break;
case 1:
$bonus = $inv['bonus'] * 4.8;
break;
case 2:
$bonus = $inv['bonus'] * 6;
break;
case 3:
$bonus = $inv['bonus'] * 6.8;
break;
case 4:
$bonus = $inv['bonus'] * 8;
break;
case 5:
$bonus = $inv['bonus'] * 16;
break;
case 6:
$bonus = $inv['bonus'] * 16;
break;
}
?>
</div>
<div class='line'></div>
<div class="item-stars center"><b>Звезды:</b> <?php for($si=1;$si<=5;$si++): ?><img src="/images/stars/<?=((int)($inv['stars']??0)>=$si?'1':'0')?>.png" alt="★"><?php endfor; ?><br>
<?php $scosts=[0=>10,1=>25,2=>50,3=>100,4=>200]; $curStars=(int)($inv['stars']??0); $dustState=game_star_chest_state((int)$user['id']); if((int)$inv['user']===(int)$user['id'] && $curStars<5): ?>
<span class="medium">Звездная пыль: <b><?=$dustState['dust']?></b> · Цена следующей звезды: <b><?=$scosts[$curStars]?></b></span><br><form method="post" action="/item/<?=$inv['id']?>/" class="inline-form"><?=security_csrf_field()?><input type="hidden" name="star_up" value="1"><button class="old-btn" type="submit">Прокачать звезду</button></form>
<br><a class="old-btn link-btn" href="/item-stars/">Звезды</a> <?php elseif($curStars>=5): ?><span class="dgreen">Максимальный уровень звезд</span><?php endif; ?></div><div class="line"></div>
<div class='menu'>
<img src='/images/icon/rune.png' alt='*'/> Руна: <?=($inv['rune'] ? '<img src="/images/icon/quality/'.$inv['rune'].'.png" alt="*"/> <font color="#9c9">+'.$rune_stats.'</font> '.$rune_stat:'<font color="#999">отсутствует</font>')?><br/>
Руна - мощное усиление вещи!<br />
<?php
if($inv['rune'] < 6 && $inv['user'] == $user['id']) {
?>
<br/><a href='/smith/runes/<?=$inv['id']?>/' class='btn'><span class='end'><span class='label'>Магазин рун</a><hr>
<?php
}
?>
<br>
<img src='/images/icon/smith.png' alt='*'/> Заточка: <font color='#9c9'>+<?=$inv['smith']?></font><br/>
<font color='#9c9'>+<?=$smith?></font> к параметрам<br/>
<?php
if($inv['smith'] < 50 && $inv['user'] == $user['id']) {
?>
<br/>
<a href='/smith/smith/<?=$inv['id']?>/' class='btn'><span class='end'><span class='label'>Заточка</a>
<?php
}
?>
<hr/>
<img src='/images/icon/quality/<?=$ownedQuality?>.png' alt='*'/> Бонус: <?=$inv['bonus']?> из <?=$all_bonus?><br/>
<font color='#9c9'>+<?=$bonus?></font> к параметрам <br/>
<?php
if($inv['bonus'] < $all_bonus && $inv['user'] == $user['id']) {
?>
<br/>
<a href='/smith/bonus/<?=$inv['id']?>/' class='btn'><span class='end'><span class='label'>Бонус вещи</a>
<?php
}
?>
</li>
</div>
<?php
if($inv['user'] == $user['id']) {
if($user['w_'.$item['w']] == $inv['id'] OR !$user['w_'.$item['w']] OR $user['w_'.$item['w']] != $inv['id']) {
?>
<div class='line'></div>
<div class='content' align='center'>
<?php
if($user['w_'.$item['w']] == $inv['id']) {
?>
<a href='/inv/move/0/<?=$inv['id']?>/' class='btn'><span class='end'><span class='label'>В сумку</a>
<?php
if($user['chest'] == 1) {
?>
<a href='/inv/move/1/<?=$inv['id']?>/' class='btn'><span class='end'><span class='label'>В сундук</a>
<?php
}
}
if($user['skill'] >= $item['skill'] && $inv['equip'] == '0') {
?>
<a href='/inv/wear/<?=$inv['id']?>/' class='btn'><span class='end'><span class='label'>Надеть</a>
<?php
}
if($inv['equip'] == 0) {
?>
<?php
}
if(isset($_GET['SendRune']) && $inv['rune'] > 0 && $inv['equip'] == 0) {
$_SESSION['item'] = $id;
exit(header('Location: /smith/SendRunes/'));
}
if($user['w_'.$item['w']] != $inv['id']) {
switch($item['quality']) {
case 0:
$_s = 0;
$_g = 0;
break;
case 1:
$_s = 100;
$_g = 0;
break;
case 2:
$_s = 250;
$_g = 0;
break;
case 3:
$_s = 500;
$_g = 0;
break;
case 4:
$_s = 1000;
$_g = 0;
break;
case 5:
$_s = 50000;
$_g = 0;
break;
case 6:
$_s = 50000;
$_g = 0;
break;
}
?>
<center/><a href='/inv/<?=($inv['place'] == 0 ? 'bag':'chest')?>/?sell=<?=$inv['id']?>' class='btn'><span class='end'><span class='label'>Продать вещь за <?=($_s ? "<img src='/images/icon/silver.png' alt='*'/> $_s":"<img src='/images/icon/gold.png' alt='*'/> $_g")?></a>
<?php
}
?>
</div>
<?php
}
}
if($equip_item && $inv['user'] != $user['id'] && $user['w_'.$item['w']]) {
$i_equip_item = db_query('SELECT * FROM `items` WHERE `id` = "'.$equip_item['item'].'"');
$i_equip_item = db_fetch_array($i_equip_item);
switch($i_equip_item['quality']) {
case 0:
$bonus = 0;
$quality = 'Простой';
$quality_color = "#908060";
break;
case 1:
$bonus = 5;
$quality = 'Обычный';
$quality_color = "#60c030";
break;
case 2:
$bonus = 10;
$quality = 'Редкий';
$quality_color = "#6090c0";
break;
case 3:
$bonus = 15;
$quality = 'Эпический';
$quality_color = "#c060f0";
break;
case 4:
$bonus = 20;
$quality = 'Легенарный';
$quality_color = "#f06000";
break;
case 5:
$bonus = 50;
$quality = 'Божественный';
$quality_color = "#909090";
break;
case 6:
$bonus = 100;
$quality = 'Сверх Божественный';
$quality_color = "#909090";
break;
}
switch($i_equip_item['w']) {
case 1:
$w = 'Голова';
break;
case 2:
$w = 'Плечи';
break;
case 3:
$w = 'Торс';
break;
case 4:
$w = 'Перчатки';
break;
case 5:
$w = 'Левая рука';
break;
case 6:
$w = 'Правая рука';
break;
case 7:
$w = 'Ноги';
break;
case 8:
$w = 'Обувь';
break;
}
?>
<div class='line'></div>
<div class='title'>На вас надето</div>
<div class='line'></div>
<div class='content'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/itemImage.php?id=<?=$equip_item['item']?>' alt='*'/></td>
<td valign='top' style='padding-left: 5px;'><img src='/images/icon/quality/<?=$i_equip_item['quality']?>.png' alt="*"/> <?=$i_equip_item['name']?>, <?=$w?>
<br/>
<small><small>
<font color='<?=$quality_color?>'><?=$quality?> [<?=$equip_item['bonus']?>/<?=$bonus?>]</font><br/>
Мастерство: <img src='/images/icon/skill.png' alt='*'/> <font color='#<?=($i_equip_item['skill'] > $user['skill'] ? 'c06060':'ffffff')?>'><?=$i_equip_item['skill']?></font>
</small></small></td>
</tr></table>
</div><div class='line'></div>
<div class='content'>
<img src='/images/icon/str.png' alt='*'/> Сила: <?=$equip_item['_str']?><br/>
<img src='/images/icon/vit.png' alt='*'/> Жизнь: <?=$equip_item['_vit']?><br/>
<img src='/images/icon/agi.png' alt='*'/> Удача: <?=$equip_item['_agi']?><br/>
<img src='/images/icon/def.png' alt='*'/> Защита:<?=$equip_item['_def']?><br/>
</div>
<?php
}
echo '</div>';
include './system/f.php';
?>