Файл: _modules/inv/index.php
Строк: 240
<?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);
# meta
$title = 'Экипировка :: '.domain;
# get
$cat = isset( $_GET['cat'] ) ? system::abs($_GET['cat']): 0;
# head
require_once ( head );
# size
$size = cache_size::get($user['id'],$user['lvl_inv']);
# inv act
$inv_json = "[{";
$q = "cat = 10 AND user = ".$user['id']." AND hide = 1 || cat = 4 AND user = ".$user['id']." AND hide = 1 || cat = 1 AND user = ".$user['id']." AND hide = 1 || cat = 3 AND user = ".$user['id']." AND hide = 1 || cat = 2 AND user = ".$user['id']." AND hide = 1";
$q = DB :: $dbh -> query("SELECT id FROM inv WHERE {$q} ORDER by cat DESC;");
while ($act = $q -> fetch()):
$act = cache_inv::get($act['id']);
$itm = cache_itm::get($act['thing']);
$inv_json.= '"name_'.$act['cat'].'":"'.system::check($itm['name']).'","id_itm_'.$act['cat'].'":"'.system::abs($itm['id']).'","id_'.$act['cat'].'":"'.system::abs($act['id']).'","cc_'.$act['cat'].'":"'.system::abs($act['cc']).'","img_'.$act['cat'].'":"'.system::check($itm['img']).'",';
endwhile;
$inv_json = substr ($inv_json , 0, -1);
$inv_json.= "}]";
$data = @json_decode($inv_json);
$inv_act ='
<div class="fights fights-about"><table width="100%"><tbody><tr>
<td width="58px" valign="top"><img width="45px" src="'.ico.'inv/10/'.(@$data[0]->img_10 == null ? 'default.png':$data[0]->img_10).'"></td>
<td valign="top"><div class="attack-text"><h1 class="human">
'.(@$data[0]->name_10 == null ? 'Слот пуст':'<a style="color: #ffa200;" href="/info/items/'.$data[0]->id_itm_10.'">'.$data[0]->name_10.'</a>').'
<span class="small" style="color: #888;">Противогаз</span></h1>
'.(@$data[0]->id_10 != null ? '<div class="quest-btn" style="margin: 5px 0"><a href="/inv/equip/'.$data[0]->id_10.'">— Снять с себя</a></div>':null).'
<div class="quest-btn" style="margin: 5px 0"></div></div></td></tr></tbody></table>
'.(@$data[0]->cc_10 != null ? '<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.$data[0]->cc_10.'%;display: block;background: #39ef39;height: 3px;"></span></div>':null).'
</div>
<div class="fights fights-about"><table width="100%"><tbody><tr>
<td width="58px" valign="top"><img width="45px" src="'.ico.'inv/4/'.(@$data[0]->img_4 == null ? 'default.png':$data[0]->img_4).'"></td>
<td valign="top"><div class="attack-text"><h1 class="human">
'.(@$data[0]->name_4 == null ? 'Слот пуст':'<a style="color: #ffa200;" href="/info/items/'.$data[0]->id_itm_4.'">'.$data[0]->name_4.'</a>').'
<span class="small" style="color: #888;">Нож</span></h1>
'.(@$data[0]->id_4 != null ? '<div class="quest-btn" style="margin: 5px 0"><a href="/inv/equip/'.$data[0]->id_4.'">— Снять с себя</a></div>':null).'
<div class="quest-btn" style="margin: 5px 0"></div></div></td></tr></tbody></table>
'.(@$data[0]->cc_4 != null ? '<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.$data[0]->cc_4.'%;display: block;background: #39ef39;height: 3px;"></span></div>':null).'
</div>
<div class="fights fights-about"><table width="100%"><tbody><tr>
<td width="58px" valign="top"><img width="45px" src="'.ico.'inv/1/'.(@$data[0]->img_1 == null ? 'default.png':$data[0]->img_1).'"></td>
<td valign="top"><div class="attack-text"><h1 class="human">
'.(@$data[0]->name_1 == null ? 'Слот пуст':'<a style="color: #ffa200;" href="/info/items/'.$data[0]->id_itm_1.'">'.$data[0]->name_1.'</a>').'
<span class="small" style="color: #888;">Броня</span></h1>
'.(@$data[0]->id_1 != null ? '<div class="quest-btn" style="margin: 5px 0"><a href="/inv/equip/'.$data[0]->id_1.'">— Снять с себя</a></div>':null).'
<div class="quest-btn" style="margin: 5px 0"></div></div></td></tr></tbody></table>
'.(@$data[0]->cc_1 != null ? '<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.$data[0]->cc_1.'%;display: block;background: #39ef39;height: 3px;"></span></div>':null).'
</div>
<div class="fights fights-about"><table width="100%"><tbody><tr>
<td width="58px" valign="top"><img width="45px" src="'.ico.'inv/3/'.(@$data[0]->img_3 == null ? 'default.png':$data[0]->img_3).'"></td>
<td valign="top"><div class="attack-text"><h1 class="human">
'.(@$data[0]->name_3 == null ? 'Слот пуст':'<a style="color: #ffa200;" href="/info/items/'.$data[0]->id_itm_3.'">'.$data[0]->name_3.'</a>').'
<span class="small" style="color: #888;">Пистолет</span></h1>
'.(@$data[0]->id_3 != null ? '<div class="quest-btn" style="margin: 5px 0"><a href="/inv/equip/'.$data[0]->id_3.'">— Снять с себя</a></div>':null).'
<div class="quest-btn" style="margin: 5px 0"></div></div></td></tr></tbody></table>
'.(@$data[0]->cc_3 != null ? '<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.$data[0]->cc_3.'%;display: block;background: #39ef39;height: 3px;"></span></div>':null).'
</div>
<div class="fights fights-about"><table width="100%"><tbody><tr>
<td width="58px" valign="top"><img width="45px" src="'.ico.'inv/2/'.(@$data[0]->img_2 == null ? 'default.png':$data[0]->img_2).'"></td>
<td valign="top"><div class="attack-text"><h1 class="human">
'.(@$data[0]->name_2 == null ? 'Слот пуст':'<a style="color: #ffa200;" href="/info/items/'.$data[0]->id_itm_2.'">'.$data[0]->name_2.'</a>').'
<span class="small" style="color: #888;">Автомат</span></h1>
'.(@$data[0]->id_2 != null ? '<div class="quest-btn" style="margin: 5px 0"><a href="/inv/equip/'.$data[0]->id_2.'">— Снять с себя</a></div>':null).'
<div class="quest-btn" style="margin: 5px 0"></div></div></td></tr></tbody></table>
'.(@$data[0]->cc_2 != null ? '<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.$data[0]->cc_2.'%;display: block;background: #39ef39;height: 3px;"></span></div>':null).'
</div>
';
# inv no act
if ($cat > 0) $thing = "user = ".$user['id']." AND hide = 0 AND cat = {$cat}";
if ($cat == 0 || $cat != 10 AND $cat != 4 AND $cat != 1 AND $cat != 3 AND $cat != 2) $thing = "user = ".$user['id']." AND hide = 0 AND cat = 10 || user = ".$user['id']." AND hide = 0 AND cat = 4 || user = ".$user['id']." AND hide = 0 AND cat = 1 || user = ".$user['id']." AND hide = 0 AND cat = 3 || user = ".$user['id']." AND hide = 0 AND cat = 2";
$cn = DB :: $dbh -> querySingle("SELECT count(id) FROM inv WHERE {$thing}");
$inv_no_act = null;
$query = DB :: $dbh -> query("SELECT id FROM inv WHERE {$thing} ORDER BY id ");
while ($inv = $query -> fetch()):
$inv = cache_inv::check($inv['id']);
$itm = cache_itm::get($inv['thing']);
$itm_cat = cache_itm_cat::get($inv['cat']);
$inv_no_act.= '
<div class="fights fights-about">
<table width="100%">
<tbody><tr>
<td width="58px" valign="top"><img width="58px" src ="'.ico.'inv/'.$itm['cat'].'/'.$itm['img'].'">
</td>
<td valign="top">
<div class="attack-text">
<h1 class="human"><img src="'.ico.'ammo.png" width="12px">
<a style="color: #ffa200;" href="/info/items/'.$itm['id'].'">'.system::check($itm['name']).'</a>
<span class="small" style="color: #888;">'.system::check($itm_cat['name']).'</span></h1><hr>
<div class="quest-btn" style="margin: 5px 0">
<a href="/inv/equip/'.$inv['id'].'?act=1">— Надеть на себя</a></div>
</div>
</td>
</tr>
</tbody></table>
<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.$inv['cc'].'%;display: block;background: #39ef39;height: 3px;">
</span></div>
</div>
';
endwhile;
# index
echo ''.system::dis().'
<div style="margin: 2px 5px;">
<div class="grid fights-link">
<div class="six columns ln">
<a href="/inv">Экипировка</a>
</div>
<div class="six columns">
<a href="/inv/objects">Предметы</a>
</div>
</div>
</div>
<div class="dialog"><h1 class="pda">
Cклад: '.$size['size'].'/'.$size['max'].' кг
<div style="background-color: #1c201e;text-align: left;color: #fff;border: 1px solid #333333;">
<span style="width: '.(round(($size['size']*100)/$size['max'],2) > 100? 100:round(($size['size']*100)/$size['max'],2)).'%;display: block;background: #e3972a;height: 3px;">
</span></div>
</h1></div>
<br>
<div class="callout">На вас надето:</div>
'.$inv_act.'
<br><div class="callout">Что имеется на складе:</div>
<br>
<div style="margin: 2px 5px;">
<div class="grid fights-link">
<div class="six columns ln">
<a href="/inv">Все</a>
</div>
<div class="six columns ">
<a href="/inv?&cat=10">Противогазы</a>
</div>
<div class="six columns ln">
<a href="/inv?&cat=4">Ножи</a>
</div>
<div class="six columns ">
<a href="/inv?&cat=1">Броня</a>
</div>
<div class="six columns ln">
<a href="/inv?&cat=3">Пистолеты</a>
</div>
<div class="six columns ">
<a href="/inv?&cat=2">Автоматы</a>
</div></div></div>
'.($cn == 0 ? '<div class="dialog"><h1 class="pda">КПК</h1><p>› В слоте нет доступной аммуниции<br></p></div>':null).'
'.$inv_no_act.'
<div class="line"></div>';
# foot
require_once ( foot );
?>