<?php

use Core\Db;

define('GAME', time());

require_once '_incl_data/__config.php';
require_once '_incl_data/class/__db_connect.php';

$urla = explode('?', $_SERVER["REQUEST_URI"]);
$url = explode('/', $urla[0]);

$rv = explode('i', $url[2]);
$rv = (int)$rv[1];
$sp = [];

$str = 'Выберите один из разделов слева, чтобы отобразить образы<br>';
if (in_array($rv, [1, 2])) {
    if ($rv == 1) {
        $sex = 0;
        //Мужские стандартные
    } else {
        $sex = 1;
        //Женские стандартные
    }
    $sp = Db::getRows(
        'select * from obraz where sex = ? and usr_add = 0 and align = 0 and clan = 0 and login = \'\' and tr = \'\' and itm = 0 and uid = 0',
        [$sex]
    );
}
if ($rv === 3) {
    $sp = Db::getRows('select * from obraz where login != \'\' or uid != 0');
}

if (!empty($sp)) {
    $str = '';
    foreach ($sp as $itm) {
        if (empty($itm['name'])) {
            $itm['name'] = 'Образ №' . $itm['id'];
        }
        if (!empty($itm['uid'])) {
            $itm['login'] = Db::getValue('select login from users where id = ?', [$itm['uid']]);
        }
        if (!empty($itm['login'])) {
            $itm['name'] = $itm['login'];
        }
        $imgsrc = "/img.new-combats.com/i/obraz/{$itm['sex']}/{$itm['img']}";
        $str .= <<<HTML
<figure style="border:1px dashed grey; float: left; margin: 5px;">
    <img src="$imgsrc" alt={$itm['name']} title={$itm['name']} width="120" height="220">
    <figcaption style="text-align: center;">{$itm['name']}</figcaption>
</figure>
HTML;
    }
}

?>
<!DOCTYPE HTML>
<html lang="ru">
<head>
    
    <title>Новый Бойцовский клуб | Библиотека образов</title>
    <link rel="stylesheet" href="/main1.css">
    <link rel="stylesheet" href="/css/obraz.css">
</head>
<body>
<div class="header">
    <img class="logo" src="https://new-combats.com/inx/newlogo3.jpg" alt="logo" title="logo">
</div>

<table class="main">
    <tr style="vertical-align: top;">
        <td style="width: 29px; background-image: url(https://new-combats.com/forum_script/img/leftground.jpg);"
            rowspan=2>
            <img src="https://img.new-combats.com/i/encicl/obrzz_08.jpg" width="29" height="256" alt="">
        </td>
        <td style="width: 218px; height: 257px;">
            <img id="imleft2" src="https://img.new-combats.com/i/encicl/obrzz_04.jpg" width="118" height="257" alt="">
            <BR>
        </td>
        <td rowspan=2>
            <h2>Библиотека образов Бойцовского Клуба</h2>
            <img src="https://img.new-combats.com/i/encicl/ln3.jpg" width="400" height="1" alt="hr"><br>
            <?= $str ?>
        </td>
        <td style='padding-left: 3px; text-align: right;'>
            <img id="imright2" height=144 src="https://img.new-combats.com/i/encicl/obrzz1.jpg" width=139 alt="">
        </td>
        <td style="vertical-align: top; background-image: url(https://new-combats.com/forum_script/img/rightground.jpg)">
            &nbsp;&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    <tr>
        <td style="vertical-align: top;">
            <span style="color: #8f0000; font-weight: bold;">Образы персонажей</span>
            <hr>
            <strong>Мужские</strong><br>
            <ul>
                <li><a href="/shadow/i1">Стандартные</a></li>
            </ul>
            <br>
            <strong>Женские</strong><br>
            <ul>
                <li><a href="/shadow/i2">Стандартные</a></li>
            </ul>
            <br>
            · <a href="/shadow/i3">Именные</a>
        </td>
        <td style="padding-bottom:50px; text-align: right; vertical-align: bottom;">
            <IMG height=236 src="https://img.new-combats.com/i/encicl/pictr_subject.jpg" width=128 alt="">
        </td>
        <td style="width: 23px; vertical-align: top; background-image: url(https://new-combats.com/forum_script/img/rightground.jpg);">
            &nbsp;
        </td>
    </tr>
</table>
<div class="footer">Copyright © <?= date('Y') ?> «www.new-combats.com»</div>
</body>
</html>