Вход Регистрация
Файл: html/admin/shkaf.php
Строк: 168
<?php
require_once ('../system/dbc.php');
require_once (
'../system/func.php');
if (!
$user OR $user['access'] < 3) {
    
?>
    <script>showContent("/");</script>
    <?php
    
exit;
}
$drespers = [];
$persequip1 $mc->query("SELECT * FROM `userbag` WHERE `id_user`='" $user['id'] . "' AND `dress`=1");
while (
$persequip $persequip1->fetch_array(MYSQLI_ASSOC)) {
    
$namedress $mc->query("SELECT * FROM `shop` WHERE `id`='" $persequip['id_shop'] . "'")->fetch_array(MYSQLI_ASSOC);
    if (
$namedress['stil'] > 0) {
        
$colorStyle = ["black""green""blue""red""yellow"];
        
$namedress['name'] = '<font style="color:' $colorStyle[$namedress['stil']] . ';font-weight: bold;">' $namedress['name'] . '</font>';
    }
    if (!isset(
$drespers[$persequip['id_punct']])) {
        
$drespers[$persequip['id_punct']] = "";
    }
    if (
$drespers[$persequip['id_punct']] != "") {
        if (
$persequip['id_punct'] == 9) {
            if (
$persequip['koll'] >= && $persequip['koll'] < 99) {
                
$drespers[$persequip['id_punct']] .= ' , ' $namedress['name'] . '(' $persequip['koll'] . ')';
            } else {
                
$drespers[$persequip['id_punct']] .= ' , ' $namedress['name'] . '(99)';
            }
        } else {
            if (
$persequip['iznos'] >= && $persequip['iznos'] < 99) {
                
$drespers[$persequip['id_punct']] .= ' , ' $namedress['name'];
            } else {
                
$drespers[$persequip['id_punct']] .= ' , ' $namedress['name'];
            }
        }
    } else {
        if (
$persequip['id_punct'] == 9) {
            if (
$persequip['koll'] >= && $persequip['koll'] < 99) {
                
$drespers[$persequip['id_punct']] .= $namedress['name'] . '(' $persequip['koll'] . ')';
            } else {
                
$drespers[$persequip['id_punct']] .= $namedress['name'] . '(99)';
            }
        } else {
            if (
$persequip['iznos'] >= && $persequip['iznos'] < 99) {
                
$drespers[$persequip['id_punct']] .= $namedress['name'];
            } else {
                
$drespers[$persequip['id_punct']] .= $namedress['name'];
            }
        }
    }
}

for (
$i 1$i 9$i++) {
    if (!isset(
$drespers[$i])) {
        
$drespers[$i] = "-";
    }
}
?>
<table><tbody>
        <tr><td><b>Оружие: </b></td><td><?= isset($drespers[1]) ? $drespers[1] : "-"?></td></tr>
        <tr><td><b>Защита: </b></td><td><?= isset($drespers[2]) ? $drespers[2] : "-"?></td></tr>
        <tr><td><b>Шлем: </b></td><td><?= isset($drespers[3]) ? $drespers[3] : "-"?></td></tr>
        <tr><td><b>Перчатки: </b></td><td><?= isset($drespers[4]) ? $drespers[4] : "-"?></td></tr>
        <tr><td><b>Доспехи: </b></td><td><?= isset($drespers[5]) ? $drespers[5] : "-"?></td></tr>
        <tr><td><b>Обувь: </b></td><td><?= isset($drespers[6]) ? $drespers[6] : "-"?></td></tr>
        <tr><td><b>Амулет: </b></td><td><?= isset($drespers[7]) ? $drespers[7] : "-"?></td></tr>
        <tr><td><b>Кольца: </b></td><td><?= isset($drespers[8]) ? $drespers[8] : "-"?></td></tr>
        <tr><td style="float: left;"><b>Пояс: </b></td><td><?= isset($drespers[9]) ? $drespers[9] : "-"?></td></tr>
    </tbody></table><br>

<?php
if ($user['access'] > 2) {
    echo 
"<center>--Админ--</center><br>";
    
$persequip3 $mc->query("SELECT * FROM `userbag` WHERE `id_user`='" $user['id'] . "' ORDER BY `userbag`.`id_punct` ASC, `id` ASC");
    while (
$persequip2 $persequip3->fetch_array(MYSQLI_ASSOC)) {
        
$namedress2 $mc->query("SELECT * FROM `shop` WHERE `id`='" $persequip2['id_shop'] . "'")->fetch_array(MYSQLI_ASSOC);
        
?> 

        <?php if ($persequip2['dress'] == "1") { ?>
            <b><?php echo $namedress2["name"]; ?></b>
            <a onclick="showContent('/admin/shkaf.php?weshEdit=h&ids=<?php echo $persequip2["id"]; ?>')"><font>[Снять]</font></a>

        <?php } else if ($persequip2['dress'] == "0") { ?>

            <?php echo $namedress2["name"]; ?>
            <a onclick="showContent('/admin/shkaf.php?weshEdit=s&ids=<?php echo $persequip2["id"]; ?>')"><font>[Одеть]</font></a>

        <?php ?> 
        <a onclick="showContent('/admin/shkaf.php?weshEdit=d&ids=<?php echo $persequip2["id"]; ?>')"><font>[Удалить]</font></a><br> <?php
    
}
    
?>
    <table style="width: 100%;margin: auto;"><tbody><tr>
                <td style="width: 50px;"><input class="id_dress" type="number" value="0" style="width: 98%;height: 40px;"></td>
                <td style="max-width: 100%;"><input onkeyup="searchdress(this.value)" class="name_dress" type="text" style="width: 98%;height: 40px;"></td>
                <td style="width: 50px;text-align: center;"><button onclick="add();" class="button" style="width:100%;height: 40px;text-align: center">Добавить</button></td>
        </tbody></tr></table>
    <div class="search">

    </div>

    <script>
        function add() {
            showContent('/admin/shkaf.php?weshEdit=a&ids=' + $(".id_dress").val());
        }
        function add2(a) {
            showContent('/admin/shkaf.php?weshEdit=a&ids=' + a);
        }

        function searchdress(etext) {
            var arr;
            $.ajax({
                type: "POST",
                url: "/admin/shop/search.php?etext=" + etext,
                dataType: "text",
                success: function (data) {
                    $(".search").html("");
                    if (data != "") {
                        arr = JSON.parse(data);
                        for (var i = 0; i < arr.length; i++) {
                            addDressSearched(arr[i].name, arr[i].level, arr[i].id);
                        }
                    }
                },
                error: function () {
                    $(".search").html("error");
                }
            });
        }

        function addDressSearched(name, level, id) {
            $(".search").append(
                    '<table style="width: 100%;margin: auto;"><tr><td style="max-width: 100%;text-align: center;">' +
                    name + ' [' + level + '] id : ' + id +
                    '</td><td style="width: 50px;text-align: center;">' +
                    '<button onclick="add2(' + id + ');" class="button" style="width:100%;height: 40px;text-align: center" >Добавить</button></td></tr></table>'
                    );
        }
    </script>

    <?php
    
if (isset($_GET['weshEdit']) && isset($_GET['ids'])) {
        echo 
$_GET['weshEdit'];

        if (
$_GET['weshEdit'] == "h" || $_GET['weshEdit'] == "s") {
            
$hs 0;
            if (
$_GET['weshEdit'] == "s") {
                
$hs 1;
            }
            
//hide - снять
            
echo $_GET['ids'] . "Снять";
            
$dresssnyatreid $mc->query("SELECT * FROM `userbag` WHERE `id_user`='" $user['id'] . "' AND `id`='" $_GET['ids'] . "'")->fetch_array(MYSQLI_ASSOC);
            
$mc->query("DELETE FROM `userbag` WHERE `id_user`='" $user['id'] . "' AND `id`='" $_GET['ids'] . "'");
            
$mc->query("INSERT INTO `userbag`("
                    
"`id_user`,"
                    
" `id_shop`,"
                    
" `id_punct`,"
                    
" `dress`,"
                    
" `iznos`,"
                    
" `id_quests`,"
                    
" `koll`,"
                    
" `max_hc`,"
                    
" `time_end`,"
                    
" `stil`,"
                    
" `BattleFlag`"
                    
") VALUES ("
                    
"'" $dresssnyatreid['id_user'] . "',"
                    
"'" $dresssnyatreid['id_shop'] . "',"
                    
"'" $dresssnyatreid['id_punct'] . "',"
                    
"'" $hs "',"
                    
"'" $dresssnyatreid['iznos'] . "',"
                    
"'" $dresssnyatreid['id_quests'] . "',"
                    
"'" $dresssnyatreid['koll'] . "',"
                    
"'" $dresssnyatreid['max_hc'] . "',"
                    
"'" $dresssnyatreid['time_end'] . "',"
                    
"'" $dresssnyatreid['stil'] . "',"
                    
"'" $dresssnyatreid['BattleFlag'] . "'"
                    
")");
        }


        if (
$_GET['weshEdit'] == "d") {
            
//hide - удалить
            
$mc->query("DELETE FROM `userbag` WHERE `id_user`='" $user['id'] . "' AND `id`='" $_GET['ids'] . "'");
        }

        if (
$_GET['weshEdit'] == "a") {
            
//add добавить
            //echo "Добавлю потом";
            
$dresssnyatreid $mc->query('SELECT * FROM `shop` WHERE `id`=' $_GET['ids'])->fetch_array(MYSQLI_ASSOC);
            
//дата истечения в unix
            
if ($dresssnyatreid['time_s'] > 0) {
                
$time_the_lapse $dresssnyatreid['time_s'] + time();
            } else {
                
$time_the_lapse 0;
            }
            
$mc->query("INSERT INTO `userbag`("
                    
"`id_user`,"
                    
" `id_shop`,"
                    
" `id_punct`,"
                    
" `dress`,"
                    
" `iznos`,"
                    
" `id_quests`,"
                    
" `koll`,"
                    
" `max_hc`,"
                    
" `time_end`,"
                    
" `stil`,"
                    
" `BattleFlag`"
                    
") VALUES ("
                    
"'" $profile['id'] . "',"
                    
"'" $dresssnyatreid['id'] . "',"
                    
"'" $dresssnyatreid['id_punct'] . "',"
                    
"'0',"
                    
"'" $dresssnyatreid['iznos'] . "',"
                    
"'" $dresssnyatreid['id_quests'] . "',"
                    
"'" $dresssnyatreid['koll'] . "',"
                    
"'" $dresssnyatreid['max_hc'] . "',"
                    
"'$time_the_lapse',"
                    
"'" $dresssnyatreid['stil'] . "',"
                    
"'" $dresssnyatreid['BattleFlag'] . "'"
                    
")");
        }




        
$arr $mc->query("SELECT `stil` FROM `userbag` WHERE `id_user` = '" $user['id'] . "' && `id_punct` < '10' && `dress` ='1' GROUP BY `stil` ASC")->fetch_all(MYSQLI_ASSOC);
        if (
count($arr) == 2) {
            
$stil $arr[1]['stil'];
        } elseif (
count($arr) == && $arr[0]['stil'] != 0) {
            
$stil $arr[0]['stil'];
        } elseif (
count($arr) < 2) {
            
$stil 0;
        } else {
            
$stil 5;
        }
        
$mc->query("UPDATE `users` SET `stil`='$stil' WHERE `id` = '" $user['id'] . "'");
        
?> <script>showContent('/admin/shkaf.php?<?php echo $user['id']; ?>/1');</script> <?php
    
}
}
$footval "main";
require_once (
'../system/foot/foot.php');
?>
Онлайн: 0
Реклама