data.php
```
<?php

/**
 * Импортирование библиотек
 */

use app\ext\Pdox;
use app\modules\module_page_cases\ext\Core;
use app\modules\module_page_cases\ext\modules\CaseManager;
use app\modules\module_page_cases\ext\modules\GroupsManager;
use app\modules\module_page_cases\ext\modules\ItemsManager;

ini_set('display_errors', false);

if (!function_exists('str_contains')) {
    function str_contains($haystack, $needle) {
        return $needle !== '' && mb_strpos($haystack, $needle) !== false;
    }
}

$cases_config = $Db->query("Core", 0, 0, "SELECT * FROM `lvl_web_cases_config`");

if( empty( $cases_config ) )
    return get_iframe(500, "Ошибка при запуске модуля! (Отсутствует конфигурация)");

/**
 * Различные условия я выделил специально отдельно, чтобы можно было легко что-нибудь удалить
 */
if( (int) $cases_config["remonts"] === 1 && !isset( $_SESSION["user_admin"] ) )
    return get_iframe(404, "Данная страница находится на доработке!");

if( (int) $cases_config["hide_for_non_auth"] === 1 && !isset( $_SESSION["steamid"] ) )
    return get_iframe(404, "Данная страница не найдена!");

if( isset( $_SESSION["user_admin"] ) )
{
    /**
     * Добавление еще одних колонок в БД
     */
    if( !isset( $cases_config["show_balance_lk"] ) )
        $Db->query("Core", 0, 0, "ALTER TABLE `lvl_web_cases_config` ADD COLUMN show_balance_lk INT DEFAULT 0, ADD COLUMN show_balance_shop INT DEFAULT 0, ADD COLUMN hide_for_non_auth INT DEFAULT 0, ADD COLUMN remonts INT DEFAULT 0;");
    
    if( !isset( $cases_config["cases_mode"] ) )
        $Db->query("Core", 0, 0, "ALTER TABLE `lvl_web_cases_config` ADD COLUMN cases_mode INT DEFAULT 1, ADD COLUMN cases_speed INT DEFAULT 2;");

    if( !$Db->mysql_column_search("Core", 0, 0, "lvl_web_cases", "countdown") )
        $Db->query("Core", 0, 0, "ALTER TABLE `lvl_web_cases` ADD COLUMN countdown INT DEFAULT 0, ADD COLUMN hide_case INT DEFAULT 0;");

    if( !$Db->mysql_column_search("Core", 0, 0, "lvl_web_cases", "shop_servers") )
        $Db->query("Core", 0, 0, "ALTER TABLE `lvl_web_cases` ADD COLUMN shop_servers VARCHAR(255) DEFAULT '{}';");

    if( !$Db->mysql_column_search("Core", 0, 0, "lvl_web_items", "desc") )
        $Db->query("Core", 0, 0, "ALTER TABLE lvl_web_items ADD COLUMN `desc` VARCHAR(255) DEFAULT NULL;");

    if( !$Db->mysql_column_search("Core", 0, 0, "lvl_web_cases_items", "order") )
        $Db->query("Core", 0, 0, "ALTER TABLE lvl_web_cases_items ADD COLUMN `order` INT(11) DEFAULT 0;");

    if( !$Db->mysql_column_search("Core", 0, 0, "lvl_web_inventory", "server") )
        $Db->query("Core", 0, 0, "ALTER TABLE lvl_web_inventory ADD COLUMN `server` VARCHAR(255) DEFAULT NULL;");
}

$pdox = new Pdox("Core", 0, 0);

if (!function_exists('tt')) {
    function tt(string $s)
    {
        $Tr = new \app\ext\Translate;
        return $Tr->get_translate_module_phrase('module_page_cases', $s);
    }
}

$Core           = new Core($pdox);

$Router->map( 'GET|POST', 'cases/', 'index' );
$Router->map( 'GET|POST', 'cases/[i:id]/', 'case' );

if( isset( $_SESSION["user_admin"] ) )
{
    $Router->map( 'GET|POST', 'cases/admin/', 'admin' );
    $Router->map( 'GET|POST', 'cases/admin/main/', 'admin_main' );
    $Router->map( 'GET|POST', 'cases/admin/change/', 'admin_change' );
    $Router->map( 'GET|POST', 'cases/admin/update/', 'update' );
}

Core::startAll( $Router->match(), $Db );

$CaseManager    = new CaseManager;
$GroupsManager  = new GroupsManager;
$ItemsManager   = new ItemsManager;

// Lazy...
isset( $_POST ) && !empty( $_POST ) && empty($_POST["get_messages"]) && empty($_POST["send_message"]) && empty($_POST["delete_message"]) && die( Core::ControllerPOST( $General ) );

$Modules->set_page_title('Кейсы' . ' | ' .  $General->arr_general['short_name']);
```


interface.php
```
<?php

$currency = $Core->getCurrency();

/** Case winners */
include(MODULES."module_page_cases/pages/line.php");

/** Interface */
include(MODULES."module_page_cases/pages/".$Core::$route.".php");

if(isset( $_SESSION['user_admin'] )): ?>
<?php endif; ?>
<script>
    const lk_cur    = "<?=$currency['lk']?>";
    const shop_cur  = "<?=$currency['shop']?>";
</script>
```

Core.php
```
<?php

namespace app\modules\module_page_cases\ext;

use app\ext\Pdox;
use app\modules\module_page_cases\ext\modules\CaseManager;
use app\modules\module_page_cases\ext\modules\FilesManager;
use app\modules\module_page_cases\ext\modules\GroupsManager;
use app\modules\module_page_cases\ext\modules\HistoryManager;
use app\modules\module_page_cases\ext\modules\ItemsManager;
use app\modules\module_page_cases\ext\modules\LKManager;
use app\modules\module_page_cases\ext\modules\SHOPManager;
use app\modules\module_page_inventory\ext\InventoryClass;

class Core
{
    /**
     * @var FilesManager 
     */
    public static $Files;

    /**
     * @var \app\ext\Db
     */
    public static $Db;

    /**
     * @var \app\ext\Pdox
     */
    public static $pdox;

    /**
     * @var string 
     */
    public static $route = "index";

    /**
     * @var int|null
     */
    public static $route_id = null;

    protected static $shop_id = null;

    public function __construct( Pdox $pdox )
    {
        self::$pdox = $pdox;
    }

    /**
     * Старт функции
     */
    public static function start()
    {
        /**
         * Задаем для дочерних функций менеджер файлов
         */
        self::$Files = new FilesManager;
    }

    /**
     * Старт всех функций
     */
    public static function startAll( $request, $Db )
    {
        self::start();

        LKManager::set_db( $Db );
        SHOPManager::set_db( $Db );

        self::$Db = $Db;

        self::$route = self::requestGet( $request );
        self::setId( $request );

        GroupsManager::run(self::$pdox);
        CaseManager::run(self::$pdox);
        ItemsManager::run(self::$pdox);
    }

    /**
     * Обработка и выбрасывание текущего роута
     * @return string
     */
    protected static function requestGet( $request )
    {
        !$request && get_iframe(404, tt("un_page"));

        return $request["target"];
    }

    /**
     * Функция покупки кейса
     */
    public static function buyCase( int $id, int $count )
    {
        if( isset( $_SESSION["steamid"] ) )
        {
            if( $case = CaseManager::get( $id ) )
            {
                if( $case["sell_type"] === "lk" )
                {
                    if( LKManager::pay( $case["price"] * $count ) )
                        return true;

                    return tt("un_error");
                }
                elseif( str_contains($case["sell_type"], "shop") )
                {
                    if( SHOPManager::pay( $case["price"] * $count, $id, self::$shop_id, $case['sell_type'] ) )
                        return true;

                    return tt("un_error");
                }
                else
                    return tt("un_error");
            }
            else
                throw new \Exception(tt("un_error"));
        }
        throw new \Exception(tt("un_error"));
    }

    /**
     * Закинуть ID
     */
    protected static function setId( $request )
    {
        if( isset( $request["params"]["id"] ) )
            self::$route_id = $request["params"]["id"];
    }

    /**
     * Получить рандомное значение, учитывая шанс выпадения
     * @param array $chances Массив вида [значение => шанс выпадения]
     */
    public static function getRandomItem(array $chances)
    {
        $selectArray = []; // Массив, из которого будем выбирать рандомное значение

        foreach ($chances as $item => $chance) {
            $selectArray = array_merge($selectArray, array_fill(0, $chance, $item));
        }
        shuffle($selectArray);
        return $selectArray[rand(0, sizeof($selectArray) - 1)];
    }

    /**
     * Проверка, есть ли у игрока такие деньжищи
     */
    protected static function checkBalance( int $case, int $count )
    {
        $case = CaseManager::get( $case );

        if( !empty( $case ) )
        {
            if( $case["sell_type"] === "lk" )
                return LKManager::check( $case["price"] * $count );
            if( $case["sell_type"] === "shop_crystal" || $case["sell_type"] === "shop_gold" )
                return SHOPManager::check( $case["price"] * $count, self::$shop_id, $case["sell_type"] );
            elseif( $case["sell_type"] === "shop" )
                return SHOPManager::check( $case["price"] * $count, self::$shop_id );
        }

        return false;
    }

    /**
     * Добавить предмет в инвентарь
     */
    protected static function addInventory( int $steam64, int $caseid, int $item, $shop_id = null )
    {
        self::$Db->query("Core", 0, 0, "INSERT INTO `lvl_web_inventory`(`steam`, `item_id`, `case_id`, `server`) VALUES (:steam, :item, :case, :server)", [
            "steam" => $steam64,
            "item" => $item,
            "case" => $caseid,
            "server" => $shop_id
        ]);

        return self::$Db->lastInsertId("Core", 0, 0);
    }

    protected static function sendWebhook( $General, $case, $item, $config, $count )
    {
        if( !empty( $config->webhook ) )
        {
            $sell_currency = null;
							
            switch( $case->sell_type ) {
                case "lk":
                    $sell_currency = $config->currency_lk;
                break;
                case "shop":
                    $sell_currency = $config->currency_shop;
                break;
                case "shop_gold":
                    $sell_currency = "голда";
                break;
                case "shop_crystal":
                    $sell_currency = "крст.";
                break;
            }

            $items = [
                [
                    "name" => "Заплатил",
                    "value" => "```".number_format($case->price, 0, '.', ' ')." $sell_currency```",
                    "inline" => true,
                ],
                [
                    "name" => "Открыто",
                    "value" => "```{$count}```",
                    "inline" => true,
                ]
            ];

            foreach( $item as $key => $val )
                $items[] = [
                    "name" => "Выиграл предмет",
                    "value" => "```{$val->name}``` - ```{$val->desc}```",
                    "inline" => false,
                ];
                
            $json = json_encode([
                "username" => "CASES",
                "avatar_url" => "https:".$General->arr_general['site']."storage/cache/img/global/logo.png",
                "file" => "content",
                "embeds" =>
                [
                    [
                        "title" => "Открыт кейс «{$case->name}»",
                        "color"    => hexdec("529EF4"),
                        "description" => "https:{$General->arr_general['site']}cases/{$case->id}",
                        "author" => [
                            "name" => $General->checkName($_SESSION['steamid64']),
                            "url" => "https:".$General->arr_general['site']."profiles/{$_SESSION['steamid64']}/?search=1",
                            "icon_url" => $General->getAvatar($_SESSION['steamid64'], 1)
                        ],
                        "thumbnail"    => [
                            "url" => "http:" . $General->arr_general['site'] . $val->img  . ""
                        ],
                        "fields" => $items
                    ],  
                ],
            ]);
            $cl = curl_init($config->webhook);
            curl_setopt($cl, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
            curl_setopt($cl, CURLOPT_POST, 1);
            curl_setopt($cl, CURLOPT_POSTFIELDS, $json);
            curl_exec($cl);
        }
    }

    /**
     * Обработчик POST контроллера
     */
    public static function ControllerPOST( $General )
    {
        $p = $_POST;

        $res_json = [];
        date_default_timezone_set('Europe/Moscow');

        if (!empty($p["action"])) 
        {
            switch ($p["action"]) 
            {
                case "getItems":
                    if (isset($p["caseid"]))
                        $res_json["success"] = ItemsManager::listWithStatic((int) $p["caseid"]);
                break;
                case "openCase":
                    if (isset($p["caseid"]) && isset($p["count"]) && $p["count"] <= 5 && isset( $_SESSION["steamid"] )) 
                    {
                        $case = CaseManager::get($p["caseid"], false);

                        if(empty($case))
                        {
                            $res_json["error"] = "Кейс не найден!";
                            break;
                        }

                        if( $case->hide_case == 1 && !isset( $_SESSION["user_admin"] ) )
                        {
                            $res_json["error"] = "Этот кейс недоступен!";
                            break;
                        }

                        if( (int) $case->countdown != 0 )
                        {
                            if( $p["count"] > 1 )
                            {
                                $res_json["error"] = "Этот кейс нельзя открыть несколько раз!";
                                break;
                            }

                            $count = CaseManager::getLastOpen($case->id);
                            if( !empty( $count ) )
                            {
                                $countWithSeconds = strtotime($count->date) + (int) $case->countdown;

                                if( $countWithSeconds > \strtotime("now") )
                                {
                                    $res_json["error"] = "Вы еще не можете открыть этот кейс!";
                                    break;
                                }
                            }
                        }

                        if( $p["shopid"] && $case->sell_type !== "lk" )
                            self::$shop_id = (int) $p['shopid'];

                        if( (int) $case->price === 0 || ( (int) $case->price > 0 && self::checkBalance( $p["caseid"], $p["count"] ) ) )
                        {
                            if( (int) $case->price > 0 )
                            {
                                try
                                {
                                    self::buyCase( $p["caseid"], $p["count"] );
                                }
                                catch( \Exception $e )
                                {
                                    $res_json["error"] = $e->getMessage();

                                    break;
                                }
                            }

                            $config = self::$pdox->table("web_cases_config")->get();
                            $webhook_items = [];
                            $items_dsss = ItemsManager::listWithPercents( $p["caseid"] );
                            for( $i = 0; $i < $p["count"]; $i++ )
                            {
                                $win = self::getRandomItem( $items_dsss );
                                $win_item = ItemsManager::get( $win );
                                $webhook_items[] = $win_item;
                                
                                HistoryManager::add( $_SESSION["steamid64"], $win, $p["caseid"], $General );
                                $history_id = self::addInventory( (int) $_SESSION["steamid64"], (int) $p["caseid"], (int) $win, self::$shop_id );

                                $res_test[] = [
                                    "winid" => $win_item->id_win,
                                    "history_id" => $history_id,
                                ];

                                CaseManager::addOpens( (int) $p["caseid"] );
                            }

                            self::sendWebhook($General, $case, $webhook_items, $config, $i);

                            !isset( $res_json["error"]) && $res_json["success"] = $res_test;
                        }
                        else
                            $res_json["error"] = tt("not_enough");
                    }
                    elseif( !isset( $_SESSION["steamid"] ) )
                        $res_json["error"] = tt("debil");
                break;
                case "sellItems":
                    $inventory = new InventoryClass(self::$pdox);
                    $inventory->setDB(self::$Db, $General);
                    $inventory->sellCuncreteItems($_POST['items']);

                    $res_json["success"] = "Успех!";
                break;
                case "getGroups":
                    $res_json["success"] = GroupsManager::listPercents();
                break;
                case "getHistory":
                    $res_json["success"] = HistoryManager::list();
                break;
                case "addgroup":
                    if( self::isa() )
                        GroupsManager::add( $_POST["name"], $_POST["chance"], $_POST["color"] );
                    
                    $res_json["success"] = tt("success");
                break;
                case "addcasegroup":
                    if( self::isa() )
                        CaseManager::addGroup( $_POST["name"] );
                    
                    $res_json["success"] = tt("success");
                break;
                case "addcase":
                    if( self::isa() )
                    {
                        if( !empty( $_POST["items"] ) )
                        {
                            // $img = filter_var($_POST["img"], FILTER_VALIDATE_URL) == false ? sprintf("/app/modules/module_page_cases/temp/img/%s", $_POST["img"]) : $_POST["img"];

                            CaseManager::add( 
                                $_POST["name"], 
                                $_POST["price"],
                                $_POST["sell_type"], 
                                $_POST["img"], 
                                (int) $_POST["group"], 
                                (int) $_POST["countdown"], 
                                isset($_POST["hide_case"]) ? $_POST["hide_case"] : null, 
                                $_POST["items"], 
                                $_POST["shop_servers"], 
                            );

                            $res_json["success"] = tt("success");

                            break;
                        }
                    }
                    $res_json["error"] = "Error";
                break;
                case "additem":
                    if( self::isa() )
                    {
                        // give_param
                        $json_value = [];
                        $give_type = null;
                        $ss = [];

                        switch( $_POST["give_type"] )
                        {
                            case "wsgk":
                                if( empty( $_POST["db_id"] ) || empty( $_POST["skin_id"] ) )
                                {
                                    $res_json["error"] = "WSGK params is empty!";
                                    break 2;
                                }

                                $json_value = [
                                    "item"      => $_POST["db_id"],
                                    "weapon_id" => $_POST["skin_id"]
                                ];
                                $give_type = "wsgk";
                            break;
                            case "shop":
                                if( empty( $_POST["shop_item"] ) )
                                {
                                    $res_json["error"] = "Shop id is required!";
                                    break 2;
                                }

                                $json_value = [
                                    "sell_price"    => $_POST["sell_price"],
                                    "duration"      => $_POST["duration"],
                                    "item_id"       => $_POST["shop_item"],
                                ];
                                $give_type = "shop";
                            break;
                            case "vip":
                                if( empty( $_POST["vip_group"] ) || empty( $_POST["time"] ) )
                                {
                                    $res_json["error"] = "Vip params is required!";
                                    break 2;
                                }

                                if( isset( $_POST["vip_servers"] ) )
                                {
                                    foreach( $_POST["vip_servers"] as $k => $v )
                                        $ss[] = $v;
                                }

                                $json_value = [
                                    "group"    => $_POST["vip_group"],
                                    "time"     => $_POST["time"],
                                    "servers"  => $ss,
                                ];
                                $give_type = "vip";
                            break;
                            case "shop_credits":
                                if( empty( $_POST["credits"] ) )
                                {
                                    $res_json["error"] = "Credits is requried";
                                    break 2;
                                }

                                if( isset( $_POST["credits_servers"] ) )
                                {
                                    foreach( $_POST["credits_servers"] as $k => $v )
                                        $ss[] = $v;
                                }

                                $json_value = [
                                    "credits"    => $_POST["credits"],
                                    "sid"        => $ss,
                                ];
                                $give_type = "shop_credits";
                            break;
                            case "rcon": 
                                if( empty( $_POST["rcon_command"] ) || empty( $_POST["rcon_server"] ) )
                                {
                                    $res_json["error"] = "RCON command is requried";
                                    break 2;
                                }

                                if( isset( $_POST["rcon_server"] ) )
                                {
                                    $ss[0] = 0;
                                    foreach( $_POST["rcon_server"] as $k => $v )
                                        $ss[] = $v;
                                }

                                $json_value = [
                                    "rcon_command"  => $_POST["rcon_command"],
                                    "sid"           => $ss
                                ];
                                $give_type = "rcon";
                            break;
                            case "lk": 
                                if( empty( $_POST["money"] ) )
                                {
                                    $res_json["error"] = "Money value is requried";
                                    break 2;
                                }

                                $json_value = [
                                    "money"  => $_POST["money"],
                                ];
                                $give_type = "lk";
                            break;
                            case "likes": 
                                if( empty( $_POST["likes"] ) )
                                {
                                    $res_json["error"] = "Число лайков обязательно!";
                                    break 2;
                                }

                                $json_value = [
                                    "likes"  => $_POST["likes"],
                                ];
                                $give_type = "likes";
                            break;
                            case "empty":
                                $give_type = "empty";
                            break;
                        }
                        
                        ItemsManager::add(
                            $_POST["img"], 
                            $_POST["name"], 
                            $_POST["desc"], 
                            $_POST["sell_type"], 
                            $_POST["sell_price_test"], 
                            $_POST["group_item"], 
                            $give_type, 
                            $json_value
                        );

                        $res_json["success"] = tt("success");
                    }
                break;
                case "deletecase":
                    if( self::isa() && !empty( $_POST["caseid"] ) )
                        CaseManager::delete( (int) $_POST["caseid"] );

                    $res_json["success"] = tt("success");
                break;
                case "deletegroup":
                    if( self::isa() && !empty( $_POST["group_id"] ) )
                        GroupsManager::delete( (int) $_POST["group_id"] );

                    $res_json["success"] = tt("success");
                break;
                case "deletecasegroup":
                    if( self::isa() && !empty( $_POST["group_id"] ) )
                        CaseManager::removeGroup( (int) $_POST["group_id"] );

                    $res_json["success"] = tt("success");
                break;
                case "deleteitem":
                    if( self::isa() && !empty( $_POST["item_id"] ) )
                        ItemsManager::delete( (int) $_POST["item_id"] );

                    $res_json["success"] = tt("success");
                break;
                case "editcase":
                    if( self::isa() && !empty( $_POST["caseid"] ) && !empty( $_POST["items_change"] ) )
                    {
                        // $img = filter_var($_POST["img"], FILTER_VALIDATE_URL) == false ? sprintf("/app/modules/module_page_cases/temp/img/%s", $_POST["img"]) : $_POST["img"];

                        CaseManager::edit( 
                            $_POST["caseid"],
                            $_POST["name"], 
                            $_POST["price"], 
                            $_POST["sell_type"], 
                            $_POST["img"], 
                            (int) $_POST["group"], 
                            (int) $_POST["countdown"], 
                            isset($_POST["hide_case"]) ? $_POST["hide_case"] : null, 
                            $_POST["items_change"],
                            $_POST["items_sort"],
                            $_POST["shop_servers"], 
                        );

                        $res_json["success"] = tt("success");

                        break;
                    }
                    $res_json["error"] = "Error";
                break;
                case "edititem":
                    if( self::isa() && !empty( $_POST["itemid"] ) )
                    {
                        $json_value = [];
                        $give_type = null;
                        $ss = [];

                        switch( $_POST["give_type"] )
                        {
                            case "wsgk":
                                if( empty( $_POST["db_id"] ) || empty( $_POST["skin_id"] ) )
                                {
                                    $res_json["error"] = "WSGK params is empty!";
                                    break 2;
                                }

                                $json_value = [
                                    "item"      => $_POST["db_id"],
                                    "weapon_id" => $_POST["skin_id"]
                                ];
                                $give_type = "wsgk";
                            break;
                            case "shop":
                                if( empty( $_POST["shop_item"] ) )
                                {
                                    $res_json["error"] = "Shop id is required!";
                                    break 2;
                                }

                                $json_value = [
                                    "sell_price"    => $_POST["sell_price"] ? $_POST["sell_price"] : 0,
                                    "duration"      => $_POST["duration"] ? $_POST["duration"] : 0,
                                    "item_id"       => $_POST["shop_item"],
                                ];
                                $give_type = "shop";
                            break;
                            case "vip":
                                if( empty( $_POST["vip_group"] ) || empty( $_POST["time"] ) )
                                {
                                    $res_json["error"] = "Vip params is required!";
                                    break 2;
                                }


                                foreach( $_POST["vip_servers"] as $k => $v )
                                    $ss[] = $v;

                                $json_value = [
                                    "group"    => $_POST["vip_group"],
                                    "time"     => $_POST["time"],
                                    "servers"  => $ss,
                                ];
                                $give_type = "vip";
                            break;
                            case "shop_credits":
                                if( empty( $_POST["credits"] ) )
                                {
                                    $res_json["error"] = "Credits is requried";
                                    break 2;
                                }
                                
                                if( isset( $_POST["credits_servers"] ) )
                                {
                                    foreach( $_POST["credits_servers"] as $k => $v )
                                        $ss[] = $v;
                                }

                                $json_value = [
                                    "credits"    => $_POST["credits"],
                                    "sid"        => $ss,
                                ];
                                $give_type = "shop_credits";
                            break;
                            case "rcon": 
                                if( empty( $_POST["rcon_command"] ) || empty( $_POST["rcon_server"] ) )
                                {
                                    $res_json["error"] = "RCON command is requried";
                                    break 2;
                                }

                                $json_value = [
                                    "rcon_command"  => $_POST["rcon_command"],
                                    "sid"           => $_POST["rcon_server"]
                                ];
                                $give_type = "rcon";
                            break;
                            case "lk": 
                                if( empty( $_POST["money"] ) )
                                {
                                    $res_json["error"] = "Money value is requried";
                                    break 2;
                                }

                                $json_value = [
                                    "money"  => $_POST["money"],
                                ];
                                $give_type = "lk";
                            break;
                            case "likes": 
                                if( empty( $_POST["likes"] ) )
                                {
                                    $res_json["error"] = "Число лайков обязательно!";
                                    break 2;
                                }

                                $json_value = [
                                    "likes"  => $_POST["likes"],
                                ];
                                $give_type = "lk";
                            break;
                            case "empty":
                                $give_type = "empty";
                            break;
                            case "steam":
                                $give_type = "steam";
                            break;
                        }

                        ItemsManager::change(
                            $_POST["itemid"], 
                            $_POST["img"], 
                            $_POST["name"],
                            $_POST["desc"],
                            $_POST["sell_type"], 
                            $_POST["sell_price_test"], 
                            $_POST["group_item"], 
                            $give_type,
                            $json_value
                        );

                        $res_json["success"] = tt("success");
                    }
                break;
                case "editgroup":
                    if( self::isa() && !empty( $_POST["group_id"] ) && !empty( $_POST["name"] ) && !empty( $_POST["chance"] ) && !empty( $_POST["color"] ) )
                        GroupsManager::change($_POST["group_id"], $_POST["name"], $_POST["color"], $_POST["chance"]);
                        
                    $res_json["success"] = tt("success");
                break;
                case "editcasegroup":
                    if( self::isa() && !empty( $_POST["group_id"] ) && !empty( $_POST["name"] ) )
                        CaseManager::editGroup($_POST["group_id"], $_POST["name"]);

                    $res_json["success"] = tt("success");
                break;
                case "editmainsettings":
                    if( self::isa() )
                    {
                        self::$pdox->table("web_cases_config")->delete();
                        self::$pdox->table("web_cases_config")->insert([
                            "currency_lk"           => $_POST["currency_lk"],
                            "currency_shop"         => $_POST["currency_shop"],
                            "webhook"               => $_POST["webhook"],
                            "cases_speed"           => $_POST["cases_speed"],
                            "cases_mode"            => $_POST["cases_mode"],
                            "show_balance_lk"       => $_POST["show_balance_lk"] == "on" ? 1 : 0,
                            "show_balance_shop"     => $_POST["show_balance_shop"] == "on" ? 1 : 0,
                            "hide_for_non_auth"     => $_POST["hide_for_non_auth"] == "on" ? 1 : 0,
                            "remonts"               => $_POST["remonts"] == "on" ? 1 : 0,
                        ]);
                    }
                    
                    $res_json["success"] = tt("success");
                break;
            }
        }

        return json_encode($res_json);
    }

    public function hexToRgb($hex, $alpha = false) 
    {
        $hex      = str_replace('#', '', $hex);
        if(strlen($hex) == 3) {
            $rgb['r'] = hexdec(substr($hex,0,1).substr($hex,0,1));
            $rgb['g'] = hexdec(substr($hex,1,1).substr($hex,1,1));
            $rgb['b'] = hexdec(substr($hex,2,1).substr($hex,2,1));
        } else {
            $rgb['r'] = hexdec(substr($hex,0,2));
            $rgb['g'] = hexdec(substr($hex,2,2));
            $rgb['b'] = hexdec(substr($hex,4,2));
        }
        if ( $alpha ) {
           $rgb['a'] = $alpha;
        }
        return implode(array_keys($rgb)) . '(' . implode(', ', $rgb) . ')';
    }

    protected static function isa()
    {
        return isset( $_SESSION["user_admin"] );
    }

    public static function getBalance()
    {
        $playerLk = (isset( self::$Db->db_data["lk"] ) ) ? (self::$Db->query("lk", 0, 0, "SELECT * FROM `lk` WHERE `auth` LIKE :auth", [
            "auth" => "%" . $_SESSION["steamid32_short"] . "%"
        ])["cash"] ?? 0) : 0;

        $prefix = self::$Db->db_data['Shop'][0]['Table'];

        $playerShop = (isset( self::$Db->db_data["Shop"] ) ) ? (self::$Db->query("Shop", 0, 0, "SELECT * FROM `{$prefix}players` WHERE `auth` LIKE :auth", [
            "auth" => "%" . $_SESSION["steamid32_short"] . "%"
        ])["money"] ?? 0) : 0;
        
        $servers = [];

        if( isset( self::$Db->db_data["Shop"] ) && sizeof( self::$Db->db_data["Shop"] ) > 1 )
        {
            foreach ( self::$Db->db_data["Shop"] as $key => $val )
            {
                $prefix = self::$Db->db_data['Shop'][$key]['Table'];

                $shop_user = self::$Db->query("Shop", $key, 0, "SELECT * FROM `{$prefix}players` WHERE `auth` LIKE :auth", [
                    "auth" => "%" . $_SESSION["steamid32_short"] . "%"
                ]);

                $servers[$val['name']] = [
                    "balance" => $shop_user["money"] ?? 0,
                    "crystal" => $shop_user["crystal"] ?? 0,
                    "gold" => $shop_user["gold"] ?? 0,
                    "id" => $key,
                    "name" => $val['name'],
                ];
            }
        }

        return [
            "lk" => $playerLk,
            "shop" => $playerShop,
            'servers' => $servers
        ];
    }

    public function getCurrency()
    {
        $currency = self::$pdox->table("web_cases_config")->get();
        return [
            "lk" => $currency->currency_lk ?? "руб.",
            "shop" => $currency->currency_shop ?? "кредит(-ов)"
        ];
    }
}

```


изучи как работает переключение между страницами