Админка: создание предметов.

This commit is contained in:
Ivor Barhansky 2022-05-27 20:02:03 +03:00
parent 0f62ee20e7
commit 5b29d5b593
2 changed files with 144 additions and 138 deletions

View File

@ -1,10 +1,17 @@
<?php <?php
# Date: 31.01.2021 (20:21) # Date: 31.01.2021 (20:21)
require_once '../config.php';
use Battles\Admin\Item;
if (isset($_POST)) {
Item::add($_POST);
}
?> ?>
<form method=post> <form method=post>
<div> <div>
<table> <table>
<caption>Добавление вещей в магазин</caption> <caption>Добавление вещей в игру</caption>
<tr> <tr>
<th id="main">Основное <th id="main">Основное
<tr> <tr>
@ -18,7 +25,7 @@
<option value="2">Цветной</option> <option value="2">Цветной</option>
</select> </select>
<tr> <tr>
<td><input name=count placeholder="Количество (шт.)"> <td><input name=count placeholder="Количество (шт.)" disabled>
<tr> <tr>
<td><select name="item_type"> <td><select name="item_type">
<option value="0" selected disabled>Тип предмета</option> <option value="0" selected disabled>Тип предмета</option>
@ -41,7 +48,7 @@
<tr> <tr>
<td><input name=durability placeholder="Макс. износ"> <td><input name=durability placeholder="Макс. износ">
<tr> <tr>
<td><input name=price placeholder="Цена (кр.)"> <td><input name=price placeholder="Цена (кр.)" disabled>
<tr> <tr>
<th id="needs">Требования <th id="needs">Требования
<tr> <tr>
@ -65,79 +72,29 @@
<tr> <tr>
<td><input name=maxu placeholder="Макс.урон"> <td><input name=maxu placeholder="Макс.урон">
<tr> <tr>
<td><input name=gsila placeholder="Сила"> <td><input name=add_strength placeholder="Сила">
<tr> <tr>
<td><input name=glovk placeholder="Ловкость"> <td><input name=add_dexterity placeholder="Ловкость">
<tr> <tr>
<td><input name=ginta placeholder="Интуиция"> <td><input name=add_intuition placeholder="Интуиция">
<tr> <tr>
<td><input name=gintel placeholder="Интеллект"> <td><input name=add_endurance placeholder="Выносливость">
<tr> <tr>
<td><input name=ghp placeholder="НР"> <td><input name=add_intelligence placeholder="Интеллект">
<tr> <tr>
<td><input name=mfkrit placeholder="Мф.крит"> <td><input name=add_wisdom placeholder="Мудрость">
<tr> <tr>
<td><input name=mfakrit placeholder="Мф.антикрит"> <td><input name=add_accuracy placeholder="Точность">
<tr> <tr>
<td><input name=mfuvorot placeholder="Мф.уворот"> <td><input name=add_evasion placeholder="Уворот">
<tr> <tr>
<td><input name=mfauvorot placeholder="Мф.антиуворот"> <td><input name=add_criticals placeholder="Крит">
<tr> <tr>
<td><input name=gnoj placeholder="Ум.ножи"> <td><input name=add_min_physical_damage placeholder="Мин.удар">
<tr> <tr>
<td><input name=gtopor placeholder="Ум.топоры"> <td><input name=add_min_physical_damage placeholder="Макс.удар">
<tr>
<td><input name=gdubina placeholder="Ум.дубины">
<tr>
<td><input name=gmech placeholder="Ум.мечи">
<tr>
<td><input name=bron1 placeholder="Броня головы">
<tr>
<td><input name=bron2 placeholder="Броня корпуса">
<tr>
<td><input name=bron3 placeholder="Броня пояса">
<tr>
<td><input name=bron4 placeholder="Броня ног">
<tr>
<td><input name=gfire placeholder="Мастерство огня">
<tr>
<td><input name=gwater placeholder="Мастерство воды">
<tr>
<td><input name=gair placeholder="Мастерство воздуха">
<tr>
<td><input name=gearth placeholder="Мастерство земли">
<tr>
<td><input name=glight placeholder="Светлая магия">
<tr>
<td><input name=ggray placeholder="Серая магия">
<tr>
<td><input name=gdark placeholder="Темная магия">
<tr>
<td><input name=encicl placeholder="В энциклопедию">
<tr>
<td><input name=magic placeholder="Наложенно заклятие">
</table> </table>
<INPUT TYPE="submit" value="Добавить"> <INPUT TYPE="submit" value="Добавить">
</div> </div>
</form> </form>
<?php
if (isset($_POST)) {
echo "Ждём лучших времён!";
//if($_POST['razdel'] !=7) $goden_tmp=0; else */
// $goden_tmp = $_POST['goden'];
//
// if ($_POST['shop'] == 1) if (mysql_query("INSERT INTO shop(name,duration,maxdur,cost,ecost,nlevel,nsila,nlovk,ninta,nvinos,nintel,nmudra,nnoj,ntopor,ndubina,nmech,nalign,minu,maxu,goden,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,gnoj,gtopor,gdubina,gmech,img,count,bron1,bron2,bron3,bron4,magic,type,massa,needident,nfire,nwater,nair,nearth,nlight,ngray,ndark,gfire,gwater,gair,gearth,glight,ggray,gdark,encicl,artefact,letter,isrep,razdel) VALUES ('" . $_POST['name'] . "','" . $_POST['duration'] . "','" . $_POST['maxdur'] . "','" . $_POST['cost'] . "','" . $_POST['ecost'] . "','" . $_POST['nlevel'] . "','" . $_POST['nsila'] . "','" . $_POST['nlovk'] . "','" . $_POST['ninta'] . "','" . $_POST['nvinos'] . "','" . $_POST['nintel'] . "','" . $_POST['nmudra'] . "','" . $_POST['nnoj'] . "','" . $_POST['ntopor'] . "','" . $_POST['ndubina'] . "','" . $_POST['nmech'] . "','" . $_POST['nalign'] . "','" . $_POST['minu'] . "','" . $_POST['maxu'] . "','" . $goden_tmp . "','" . $_POST['gsila'] . "','" . $_POST['glovk'] . "','" . $_POST['ginta'] . "','" . $_POST['gintel'] . "','" . $_POST['ghp'] . "','" . $_POST['mfkrit'] . "','" . $_POST['mfakrit'] . "','" . $_POST['mfuvorot'] . "','" . $_POST['mfauvorot'] . "','" . $_POST['gnoj'] . "','" . $_POST['gtopor'] . "','" . $_POST['gdubina'] . "','" . $_POST['gmech'] . "','" . $_POST['img'] . "','" . $_POST['count'] . "','" . $_POST['bron1'] . "','" . $_POST['bron2'] . "','" . $_POST['bron3'] . "','" . $_POST['bron4'] . "','" . $_POST['magic'] . "','" . $_POST['type'] . "','" . $_POST['massa'] . "','" . $_POST['needident'] . "','" . $_POST['nfire'] . "','" . $_POST['nwater'] . "','" . $_POST['nair'] . "','" . $_POST['nearth'] . "','" . $_POST['nlight'] . "','" . $_POST['ngray'] . "','" . $_POST['ndark'] . "','" . $_POST['gfire'] . "','" . $_POST['gwater'] . "','" . $_POST['gair'] . "','" . $_POST['gearth'] . "','" . $_POST['glight'] . "','" . $_POST['ggray'] . "','" . $_POST['gdark'] . "','" . $_POST['encicl'] . "','0','" . $_POST['letter'] . "','" . $_POST['isrep'] . "','" . $_POST['razdel'] . "');")) {
// echo "Предмет успешно добавлен";
// } else {
// echo "Предмет не был добавлен!-1";
// };
//
// if ($_POST['shop'] == 2) if (mysql_query("INSERT INTO fshop(name,duration,maxdur,cost,ecost,nlevel,nsila,nlovk,ninta,nvinos,nintel,nmudra,nnoj,ntopor,ndubina,nmech,nalign,minu,maxu,goden,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,gnoj,gtopor,gdubina,gmech,img,count,bron1,bron2,bron3,bron4,magic,type,massa,needident,nfire,nwater,nair,nearth,nlight,ngray,ndark,gfire,gwater,gair,gearth,glight,ggray,gdark,letter,isrep,razdel) VALUES ('" . $_POST['name'] . "','" . $_POST['duration'] . "','" . $_POST['maxdur'] . "','" . $_POST['cost'] . "','" . $_POST['ecost'] . "','" . $_POST['nlevel'] . "','" . $_POST['nsila'] . "','" . $_POST['nlovk'] . "','" . $_POST['ninta'] . "','" . $_POST['nvinos'] . "','" . $_POST['nintel'] . "','" . $_POST['nmudra'] . "','" . $_POST['nnoj'] . "','" . $_POST['ntopor'] . "','" . $_POST['ndubina'] . "','" . $_POST['nmech'] . "','" . $_POST['nalign'] . "','" . $_POST['minu'] . "','" . $_POST['maxu'] . "','" . $goden_tmp . "','" . $_POST['gsila'] . "','" . $_POST['glovk'] . "','" . $_POST['ginta'] . "','" . $_POST['gintel'] . "','" . $_POST['ghp'] . "','" . $_POST['mfkrit'] . "','" . $_POST['mfakrit'] . "','" . $_POST['mfuvorot'] . "','" . $_POST['mfauvorot'] . "','" . $_POST['gnoj'] . "','" . $_POST['gtopor'] . "','" . $_POST['gdubina'] . "','" . $_POST['gmech'] . "','" . $_POST['img'] . "','" . $_POST['count'] . "','" . $_POST['bron1'] . "','" . $_POST['bron2'] . "','" . $_POST['bron3'] . "','" . $_POST['bron4'] . "','" . $_POST['magic'] . "','" . $_POST['type'] . "','" . $_POST['massa'] . "','" . $_POST['needident'] . "','" . $_POST['nfire'] . "','" . $_POST['nwater'] . "','" . $_POST['nair'] . "','" . $_POST['nearth'] . "','" . $_POST['nlight'] . "','" . $_POST['ngray'] . "','" . $_POST['ndark'] . "','" . $_POST['gfire'] . "','" . $_POST['gwater'] . "','" . $_POST['gair'] . "','" . $_POST['gearth'] . "','" . $_POST['glight'] . "','" . $_POST['ggray'] . "','" . $_POST['gdark'] . "','" . $_POST['letter'] . "','" . $_POST['isrep'] . "','" . $_POST['razdel'] . "');")) {
// echo "Предмет успешно добавлен";
// } else {
// echo "Предмет не был добавлен!" . mysql_error();
// };
//
}
//End item adder

View File

@ -0,0 +1,49 @@
<?php
namespace Battles\Admin;
use Battles\Database\Db;
class Item
{
public static function add(array $params): void
{
$query = 'insert into items (
name, item_type, durability,
need_strength, need_dexterity, need_intuition, need_endurance, need_intelligence, need_wisdom,
add_strength, add_dexterity, add_intuition, add_endurance, add_intelligence, add_wisdom,
add_accuracy, add_evasion, add_criticals, add_min_physical_damage, add_max_physical_damage,
image, weight)
values (
:name, :item_type, :durability,
:need_strength, :need_dexterity, :need_intuition, :need_endurance, :need_intelligence, :need_wisdom,
:add_strength, :add_dexterity, :add_intuition, :add_endurance, :add_intelligence, :add_wisdom,
:add_accuracy, :add_evasion, :add_criticals, :add_min_physical_damage, :add_max_physical_damage,
:image, :weight)';
$values = [
'name' => $params['name'] ?? uniqid(),
'item_type' => $params['item_type'],
'durability' => $params['durability'] ?? 1,
'need_strength' => $params['need_strength'] ?? 0,
'need_dexterity' => $params['need_dexterity'] ?? 0,
'need_intuition' => $params['need_intuition'] ?? 0,
'need_endurance' => $params['need_endurance'] ?? 0,
'need_intelligence' => $params['need_intelligence'] ?? 0,
'need_wisdom' => $params['need_wisdom'] ?? 0,
'add_strength' => $params['add_strength'] ?? 0,
'add_dexterity' => $params['add_dexterity'] ?? 0,
'add_intuition' => $params['add_intuition'] ?? 0,
'add_endurance' => $params['add_endurance'] ?? 0,
'add_intelligence' => $params['add_intelligence'] ?? 0,
'add_wisdom' => $params['add_wisdom'] ?? 0,
'add_accuracy' => $params['add_accuracy'] ?? 0,
'add_evasion' => $params['add_evasion'] ?? 0,
'add_criticals' => $params['add_criticals'] ?? 0,
'add_min_physical_damage' => $params['add_min_physical_damage'] ?? 0,
'add_max_physical_damage' => $params['add_max_physical_damage'] ?? 0,
'image' => $params['image'] ?? 'noitem.png',
'weight' => $params['weight'] ?? 1,
];
Db::getInstance()->execute($query, $values);
}
}