Файл: html/admin/heroes.php
Строк: 281
<?php
require_once '../system/func.php';
require_once '../system/header.php';
if (!$user OR $user['access'] < 3) {
?><script>showContent("/");</script><?php
exit;
}
if(isset($_GET['saveShop']) && isset($_GET['idshop']) && isset($_GET['idhero']) && isset($_GET['punct'])){
$id = intval($_GET['idhero']);
$shop = intval($_GET['idshop']);
$punct = intval($_GET['punct']);
if(!empty($shop)){
if($mc->query("INSERT INTO `shop_heroes` (`id_hero`,`id_shop`,`punct`) VALUES ('".$id."','".$shop."','".$punct."')")){
?><script>showContent("/admin/heroes.php?shop&id=<?=$id;?>");</script><?php
}
}
}
if(isset($_GET['shop']) && isset($_GET['delete'])){
$id = intval($_GET['delete']);
if($mc->query("DELETE FROM `shop_heroes` WHERE `id` = '".$id."'")){
?><script>showContent("/admin/heroes.php?shop&id=<?=$id;?>");</script><?php
}
}
if (isset($_GET['save']) && isset($_GET['id']) && isset($_GET['level']) && isset($_GET['name']) && isset($_GET['platinum'])) {
if ($mc->query("UPDATE `heroes` SET "
. "`level` = '" . $_GET['level'] . "' ,"
. "`platinum` = '" . $_GET['platinum'] . "' ,"
. "`name` = '" . $_GET['name'] . "'"
. " WHERE `id` = '" . $_GET['id'] . "'")) {
message(urlencode("сохранено"));
} else {
message(urlencode("<font style='color:red'>не сохранено</font>"));
}
}
if (isset($_GET['dell']) && isset($_GET['id'])) {
if ($mc->query("DELETE FROM `heroes` WHERE `id` = '" . $_GET['id'] . "'")) {
message(urlencode("удалено"));
} else {
message(urlencode("<font style='color:red'>не удалено</font>"));
}
}
if (isset($_GET['add']) && isset($_GET['level']) && isset($_GET['name']) && isset($_GET['platinum'])) {
if ($mc->query("INSERT INTO `heroes`("
. "`id`,"
. "`level`,"
. "`platinum`,"
. "`name`"
. ") VALUES ("
. "NULL,"
. "'" . $_GET['level'] . "',"
. "'" . $_GET['platinum'] . "',"
. "'" . $_GET['name'] . "'"
. ")")
) {
message(urlencode("создано"));
} else {
message(urlencode("<font style='color:red'>не создано</font>"));
}
}
if(isset($_GET['shop']) && isset($_GET['id'])){
//if(!isset($_GET['shop']) && !isset($_GET['id']) && !isset($_GET['punct'])){
$hero = $mc->query("SELECT * FROM `heroes` WHERE `id` = '".intval($_GET['id'])."'")->fetch_array(MYSQLI_ASSOC);
$shop_heroes = $mc->query("SELECT * FROM `shop_heroes` WHERE `id_hero` = '".intval($hero['id'])."'")->fetch_all(MYSQLI_ASSOC);
$or;
$shit;
$shlem;
$per;
$dos;
$ob;
$am;
$kol = [];
$is = ",";
for($i = 0; $i < count($shop_heroes); $i++){
$shop = $mc->query("SELECT * FROM `shop` WHERE `id` = '".$shop_heroes[$i]['id_shop']."'")->fetch_array(MYSQLI_ASSOC);
if($shop_heroes[$i]['punct'] == 1){
$or = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 2){
$shit = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 3){
$shlem = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 4){
$per = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 5){
$dos = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 6){
$ob = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 7){
$am = $shop['name'];
}else if($shop_heroes[$i]['punct'] == 8){
$kol[] = $shop['name'];
$is = ",";
}
}
if(is_array($kol) && empty($kol)){
$kol[0] = "";
$is = "-";
$kol[1] = "";
}
$countShop = $mc->query("SELECT COUNT(*) FROM `shop_heroes` WHERE `id_hero` = '".intval($hero['id'])."'")->fetch_array(MYSQLI_ASSOC);
?>
<table><tbody>
<?=$countShop['COUNT(*)'];?>/56
<tr><td><b>Оружие: </b></td><td><?= isset($or) ? $or : "-"; ?></td></tr>
<tr><td><b>Защита: </b></td><td><?= isset($shit) ? $shit : "-"; ?></td></tr>
<tr><td><b>Шлем: </b></td><td><?= isset($shlem) ? $shlem : "-"; ?></td></tr>
<tr><td><b>Перчатки: </b></td><td><?= isset($per) ? $per : "-"; ?></td></tr>
<tr><td><b>Доспехи: </b></td><td><?= isset($dos) ? $dos : "-"; ?></td></tr>
<tr><td><b>Обувь: </b></td><td><?= isset($ob) ? $ob : "-"; ?></td></tr>
<tr><td><b>Амулет: </b></td><td><?= isset($am) ? $am : "-"; ?></td></tr>
<tr><td><b>Кольца: </b></td><td><?= $kol[0].$is.$kol[1];?></td></tr>
</tbody></table>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=1')">Оружие</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=2')">Защита</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=3')">Шлем</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=4')">Перчатки</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=5')">Доспехи</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=6')">Обувь</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=7')">Амулет</div></center>
<center><div class="button_alt_01 arrowPunctShop1" onclick="showContent('/admin/heroes.php?shop&id=<?=$hero['id'];?>&punct=8')">Кольца</div></center>
<?php
}
if(isset($_GET['shop']) && isset($_GET['id']) && isset($_GET['punct'])){
$name = "";
$punct = $_GET['punct'];
if($punct == 1){
$name = "Оружие";
}else if($punct == 2){
$name = "Защита";
}else if($punct == 3){
$name = "Шлем";
}else if($punct == 4){
$name = "Перчатки";
}else if($punct == 5){
$name = "Доспехи";
}else if($punct == 6){
$name = "Обувь";
}else if($punct == 7){
$name = "Амулет";
}else if($punct == 8){
$name = "Кольца";
}
$shop = $mc->query("SELECT * FROM `shop_heroes` WHERE `id_hero` = '".intval($_GET['id'])."' AND `punct` = '".$punct."'")->fetch_all(MYSQLI_ASSOC);
for($i = 0; $i < count($shop); $i++){
$shopS = $mc->query("SELECT * FROM `shop` WHERE `id` = '".$shop[$i]['id_shop']."'")->fetch_array(MYSQLI_ASSOC);
?><hr><a onclick="showContent('admin/heroes.php?shop&delete=<?=$shop[$i]['id'];?>')">Удалить (<?=$shopS['name'];?>)</a></hr><br>
<?php
}
?>
<center><?=$name;?></center>
<table class="table_block2">
<tr>
<td class="block101" style="width: 2%"></td>
<td class="block102" style="width: 96%"></td>
<td class="block103" style="width: 2%"></td>
</tr>
<tr>
<td class="block104" style="width: 2%"></td>
<td class="block105" style="width: 96%;text-align: center;">
<center>
<p>ВВЕДИТЕ АЙДИ ПРЕДМЕТА</p>
<input style="text-align: center;" class="buttonregInput" type="text" id="id" maxlength="16" value="" placeholder="Ник">
<div class="button_alt_01" onclick="showContent('/admin/heroes.php?saveShop&idshop='+ $('#id').val()+'&idhero=<?=$_GET['id'];?>&punct=<?=$punct;?>');"> Добавить</div>
</center>
<td class="block106" style="width: 2%"></td>
</tr>
<tr>
<td class="block107"></td>
<td class="block108"></td>
<td class="block109"></td>
</tr>
</table><?php
}
$hero = $mc->query("SELECT * FROM `heroes` ")->fetch_all(MYSQLI_ASSOC);
if(!isset($_GET['shop']) && !isset($_GET['id'])){
?>
<details>
<summary style='text-align: center'>-- редактор персонажей --</summary>
<?php
for($i = 0; $i < count($hero); $i++){ ?>
<?=$hero[$i]['id'];?>)<table style="width: 98%;margin: auto;">
<tr>
<td><input type='text' id='id_<?= $i; ?>' value="<?= $hero[$i]['id']; ?>" hidden></td>
<td style="width:30px"><input type='text' id='platinum_<?= $i; ?>' style="width:100%;text-align: center" placeholder="платина" value="<?= $hero[$i]['platinum']; ?>"></td>
<td style="width:80px"><input type='text' id='name_<?= $i; ?>' style="width:100%;text-align: center" placeholder="название" value="<?= $hero[$i]['name']; ?>"></td>
<td style="max-width:100%"><input type='text' id='level_<?= $i; ?>' style="width:100%;text-align: center" placeholder="название" value="<?= $hero[$i]['level']; ?>"></td>
</tr>
</table>
<table style="width: 98%;margin: auto;">
<tr>
<td style="max-width:100%"><button onclick="showContent('/admin/heroes.php?save&id=' + $('#id_<?= $i; ?>').val() + '&level=' + $('#level_<?= $i; ?>').val() + '&name=' + $('#name_<?= $i; ?>').val() + '&platinum=' + $('#platinum_<?=$i;?>').val())" class="button" style="width:100%;text-align: center" >save</button></td>
<td style="width:80px" ><button onclick="showContent('/admin/heroes.php?dell&id=' + $('#id_<?= $i; ?>').val())" class="button" style="width:100%;text-align: center" >delete</button></td>
</tr>
</table>
<hr class="hr_01"/>
<?php
}
?>
</details>
<details>
<summary style='text-align: center'>-- Создать Персонажа --</summary>
<table style="width: 98%;margin: auto;">
<tr>
<td style="width:30px"><input type='text' id='platinum_new' style="width:100%;text-align: center" placeholder="платина" value=""></td>
<td style="width:80px"><input type='text' id='level_new' style="width:100%;text-align: center" placeholder="уровень" value=""></td>
<td style="max-width:100%"><input type='text' id='name_new' style="width:100%;text-align: center" placeholder="название" value=""></td>
</tr>
</table>
<table style="width: 98%;margin: auto;">
<tr>
<td style="max-width:100%"><button onclick="showContent('/admin/heroes.php?add&level=' + $('#level_new').val() + '&name=' + $('#name_new').val() + '&platinum='+ $('#platinum_new').val())" class="button" style="width:100%;text-align: center" >add new</button></td>
</tr>
</table>
<hr class="hr_01"/>
</details>
<details>
<summary style='text-align: center'>-- Снаряжение персонажа--</summary>
<?php for($i = 0; $i < count($hero); $i++){?>
<center><a onclick="showContent('/admin/heroes.php?shop&id=<?=$hero[$i]['id'];?>')"><?= $hero[$i]['name'];?> [<?=$hero[$i]['level'];?>]</a></center><br>
<?php } ?>
</details>
<details>
<summary style='text-align: center'>-- Ещё что-то очень важное--</summary>
</details>
<?php
}
$footval = 'adminindex';
include '../system/foot/foot.php';
?>