Alpha V2.5.1
This commit is contained in:
parent
c2a8442240
commit
3567b3666d
326
admin.php
326
admin.php
@ -338,7 +338,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST["
|
||||
$required_quantity = (int)$_POST["required_quantity"];
|
||||
|
||||
if ($required_quantity <= 0) {
|
||||
header("Location: admin.php?tab=levels&error=invalid_quantity");
|
||||
header("Location: admin.php?tab=levels&error=invalid_amount");
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -409,15 +409,21 @@ if (isset($_GET['delete_resource'])) {
|
||||
}
|
||||
|
||||
// Handle Guild System Config
|
||||
error_log(print_r($_POST, true));
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST["action"] === "update_guild_requirements") {
|
||||
$db->exec("DELETE FROM guild_creation_requirements");
|
||||
$stmt = $db->prepare("INSERT INTO guild_creation_requirements (resource_id, quantity) VALUES (?, ?)");
|
||||
$stmt = $db->prepare("INSERT INTO guild_creation_requirements (resource_id, amount) VALUES (?, ?)");
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (strpos($key, "res_") === 0 && (int)$value > 0) {
|
||||
if (strpos($key, "res_") === 0 && (int)$value >= 0) {
|
||||
$res_id = (int)str_replace("res_", "", $key);
|
||||
$stmt->execute([$res_id, (int)$value]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['guild_member_limit'])) {
|
||||
$stmt = $db->prepare("UPDATE guild_restrictions SET value = ? WHERE restriction_key = 'member_limit'");
|
||||
$stmt->execute([(int)$_POST['guild_member_limit']]);
|
||||
}
|
||||
header("Location: admin.php?tab=guilds&success=1");
|
||||
exit;
|
||||
}
|
||||
@ -563,6 +569,8 @@ $lootboxes_list = [];
|
||||
$project_logs_list = [];
|
||||
$levels_list = [];
|
||||
$ranks_list = [];
|
||||
$guild_requirements = [];
|
||||
$guild_member_limit = 50;
|
||||
|
||||
if ($tab === 'users') {
|
||||
$users_list = $db->query("SELECT id, username, email, role FROM users ORDER BY username ASC")->fetchAll();
|
||||
@ -615,6 +623,10 @@ if ($tab === 'users') {
|
||||
$lb['items'] = $stmt_i->fetchAll();
|
||||
}
|
||||
unset($lb);
|
||||
} elseif ($tab === 'guilds') {
|
||||
$guild_requirements = $db->query("SELECT r.id, r.name, r.icon, gr.amount FROM game_resources r LEFT JOIN guild_creation_requirements gr ON r.id = gr.resource_id")->fetchAll();
|
||||
$stmt = $db->query("SELECT value FROM guild_restrictions WHERE restriction_key = 'member_limit'");
|
||||
$guild_member_limit = $stmt->fetchColumn() ?: 50;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -714,7 +726,7 @@ if ($tab === 'users') {
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<?php if (isset($_GET['error']) && $_GET['error'] === 'invalid_quantity'): ?>
|
||||
<?php if (isset($_GET['error']) && $_GET['error'] === 'invalid_amount'): ?>
|
||||
<div class="success-msg" style="background: #bf616a; color: #fff;"><i class="fa-solid fa-triangle-exclamation"></i> Erreur : La quantité doit être un nombre strictement positif.</div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($_GET['success'])): ?>
|
||||
@ -727,9 +739,6 @@ if ($tab === 'users') {
|
||||
<a href="?tab=users" class="tab-link <?php echo $tab === 'users' ? 'active' : ''; ?>"><i class="fa-solid fa-users"></i> Utilisateurs</a>
|
||||
<a href="?tab=levels" class="tab-link <?php echo $tab === 'levels' ? 'active' : ''; ?>"><i class="fa-solid fa-layer-group"></i> Niveaux</a>
|
||||
<a href="?tab=ranks" class="tab-link <?php echo $tab === 'ranks' ? 'active' : ''; ?>"><i class="fa-solid fa-medal"></i> Grades</a>
|
||||
} elseif ($tab === 'guilds') {
|
||||
$guild_requirements = $db->query("SELECT r.id, r.name, gr.quantity FROM game_resources r LEFT JOIN guild_creation_requirements gr ON r.id = gr.resource_id")->fetchAll();
|
||||
|
||||
<a href="?tab=badges" class="tab-link <?php echo $tab === 'badges' ? 'active' : ''; ?>"><i class="fa-solid fa-id-badge"></i> Titres & Badges</a>
|
||||
<a href="?tab=guilds" class="tab-link <?php echo $tab === "guilds" ? "active" : ""; ?>"><i class="fa-solid fa-building-shield"></i> Gestion de guilde</a>
|
||||
</div>
|
||||
@ -938,23 +947,28 @@ if ($tab === 'users') {
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
} elseif ($tab === 'guilds') {
|
||||
$guild_requirements = $db->query("SELECT r.id, r.name, gr.quantity FROM game_resources r LEFT JOIN guild_creation_requirements gr ON r.id = gr.resource_id")->fetchAll();
|
||||
|
||||
<?php elseif ($tab === 'guilds'): ?>
|
||||
<?php elseif ($tab === 'guilds'): ?>
|
||||
<h3 style="color: #88c0d0;">Gestion des Guildes</h3>
|
||||
<div class="form-card">
|
||||
<h4>Coût de création d'une guilde</h4>
|
||||
<form method="POST">
|
||||
<h4>Paramètres globaux des Guildes</h4>
|
||||
<form method="POST" action="admin.php?tab=guilds">
|
||||
<input type="hidden" name="action" value="update_guild_requirements">
|
||||
<div class="form-group">
|
||||
<label>Limite de membres par guilde</label>
|
||||
<input type="number" name="guild_member_limit" value="<?php echo htmlspecialchars($guild_member_limit); ?>">
|
||||
</div>
|
||||
|
||||
<h4>Coût de création</h4>
|
||||
<table>
|
||||
<thead><tr><th>Ressource</th><th>Quantité requise</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($guild_requirements as $req): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($req["name"]); ?></td>
|
||||
<td><input type="number" name="res_<?php echo $req["id"]; ?>" value="<?php echo $req["quantity"] ?: 0; ?>"></td>
|
||||
<td>
|
||||
<i class="fa-solid <?php echo htmlspecialchars($req['icon'] ?: 'fa-gem'); ?>"></i>
|
||||
<?php echo htmlspecialchars($req["name"]); ?>
|
||||
</td>
|
||||
<td><input type="number" name="res_<?php echo $req["id"]; ?>" value="<?php echo $req["amount"] ?: 0; ?>"></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
@ -1290,15 +1304,12 @@ if ($tab === 'users') {
|
||||
<label style="font-size: 10px;">Nombre de factions</label>
|
||||
<div style="display: flex; gap: 5px;">
|
||||
<select name="orbital_count_op" id="rule_orb_op" style="width: 70px;">
|
||||
<option value="">-
|
||||
</option>
|
||||
<option value="=">=
|
||||
</option><option value=">">>
|
||||
</option><option value="<"><
|
||||
</option>
|
||||
<option value=">=">>=
|
||||
</option><option value="<="><=
|
||||
</option>
|
||||
<option value="">-</option>
|
||||
<option value="=">=</option>
|
||||
<option value=">">></option>
|
||||
<option value="<"><</option>
|
||||
<option value=">=">>=</option>
|
||||
<option value="<="><=</option>
|
||||
</select>
|
||||
<input type="number" name="orbital_count_val" id="rule_orb_val" placeholder="0">
|
||||
</div>
|
||||
@ -1336,15 +1347,12 @@ if ($tab === 'users') {
|
||||
<label style="font-size: 10px;">Nombre de factions</label>
|
||||
<div style="display: flex; gap: 5px;">
|
||||
<select name="terrestrial_count_op" id="rule_terr_op" style="width: 70px;">
|
||||
<option value="">-
|
||||
</option>
|
||||
<option value="=">=
|
||||
</option><option value=">">>
|
||||
</option><option value="<"><
|
||||
</option>
|
||||
<option value=">=">>=
|
||||
</option><option value="<="><=
|
||||
</option>
|
||||
<option value="">-</option>
|
||||
<option value="=">=</option>
|
||||
<option value=">">></option>
|
||||
<option value="<"><</option>
|
||||
<option value=">=">>=</option>
|
||||
<option value="<="><=</option>
|
||||
</select>
|
||||
<input type="number" name="terrestrial_count_val" id="rule_terr_val" placeholder="0">
|
||||
</div>
|
||||
@ -1998,256 +2006,6 @@ function editStatus(data) {
|
||||
updateMSLabel('ms_orb');
|
||||
updateMSLabel('ms_terr');
|
||||
}
|
||||
|
||||
function editSettlementType(data) {
|
||||
document.getElementById('set_t_id').value = data.id;
|
||||
document.getElementById('set_t_name').value = data.name;
|
||||
document.getElementById('set_t_slug').value = data.slug;
|
||||
document.getElementById('set_t_desc').value = data.description;
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
function resetSettlementTypeForm() { document.getElementById('settlementTypeForm').reset(); document.getElementById('set_t_id').value = 0; }
|
||||
|
||||
function editModifier(data) {
|
||||
document.getElementById('mod_id').value = data.id;
|
||||
document.getElementById('mod_name').value = data.name;
|
||||
document.getElementById('mod_slug').value = data.slug || '';
|
||||
document.getElementById('mod_type').value = data.type;
|
||||
document.getElementById('mod_desc').value = data.description;
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
function resetModifierForm() { document.getElementById('modifierForm').reset(); document.getElementById('mod_id').value = 0; }
|
||||
|
||||
function editFaction(data) {
|
||||
document.getElementById('fac_id').value = data.id;
|
||||
document.getElementById('fac_name').value = data.name;
|
||||
document.getElementById('fac_slug').value = data.slug || '';
|
||||
const color = data.color || '#808080';
|
||||
document.getElementById('fac_color').value = color;
|
||||
if (document.getElementById('fac_color_picker')) {
|
||||
document.getElementById('fac_color_picker').value = color.startsWith('#') ? color : '#808080';
|
||||
}
|
||||
document.getElementById('fac_fa_icon').value = data.fa_icon || '';
|
||||
|
||||
// Handle Alliances
|
||||
document.querySelectorAll('.alliance-checkbox').forEach(cb => cb.checked = false);
|
||||
document.querySelectorAll('.alliance-label').forEach(lbl => lbl.style.display = 'flex');
|
||||
|
||||
// Hide current faction from alliance list
|
||||
const currentLabel = document.querySelector(`.alliance-label[data-id="${data.id}"]`);
|
||||
if (currentLabel) currentLabel.style.display = 'none';
|
||||
|
||||
if (data.alliance_ids) {
|
||||
data.alliance_ids.forEach(aid => {
|
||||
const cb = document.querySelector(`.alliance-checkbox[value="${aid}"]`);
|
||||
if (cb) cb.checked = true;
|
||||
});
|
||||
}
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
function resetFactionForm() {
|
||||
document.getElementById('factionForm').reset();
|
||||
document.getElementById('fac_id').value = 0;
|
||||
document.getElementById('fac_color').value = '#808080';
|
||||
document.getElementById('fac_color_picker').value = '#808080';
|
||||
document.querySelectorAll('.alliance-checkbox').forEach(cb => cb.checked = false);
|
||||
document.querySelectorAll('.alliance-label').forEach(lbl => lbl.style.display = 'flex');
|
||||
}
|
||||
|
||||
function editResource(data) {
|
||||
document.getElementById('res_id').value = data.id;
|
||||
document.getElementById('res_name').value = data.name;
|
||||
document.getElementById('res_slug').value = data.slug;
|
||||
document.getElementById('res_icon').value = data.icon || '';
|
||||
document.getElementById('res_desc').value = data.description || '';
|
||||
document.getElementById('res_show').checked = (data.show_in_header == 1);
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
function resetResourceForm() { document.getElementById('resourceForm').reset(); document.getElementById('res_id').value = 0; }
|
||||
|
||||
// --- LOOTBOX SYSTEM ---
|
||||
function addRollRow(count = 1, prob = 100) {
|
||||
const container = document.getElementById('rolls_container');
|
||||
const row = document.createElement('div');
|
||||
row.className = 'sub-form-row';
|
||||
row.innerHTML = `
|
||||
<input type="number" name="rolls_count[]" value="${count}" placeholder="Nb total" min="0">
|
||||
<input type="number" name="rolls_prob[]" value="${prob}" placeholder="Chance %" step="0.01">
|
||||
<div class="btn-del-row" onclick="this.parentElement.remove()">×</div>
|
||||
`;
|
||||
container.appendChild(row);
|
||||
}
|
||||
|
||||
function toggleItemType(cb) {
|
||||
const row = cb.closest('.sub-form-row');
|
||||
const probInput = row.querySelector('.item-prob-input');
|
||||
const typeLabel = row.querySelector('.type-label');
|
||||
if (cb.checked) {
|
||||
probInput.style.visibility = 'hidden';
|
||||
probInput.value = 100;
|
||||
typeLabel.textContent = 'DIRECT';
|
||||
typeLabel.style.color = '#a3be8c';
|
||||
} else {
|
||||
probInput.style.visibility = 'visible';
|
||||
typeLabel.textContent = 'POULE';
|
||||
typeLabel.style.color = '#8c92a3';
|
||||
}
|
||||
}
|
||||
|
||||
function addItemRow(slug = '', prob = 0, qmin = 1, qmax = 1, isGuaranteed = 0) {
|
||||
const container = document.getElementById('items_container');
|
||||
const rowIdx = container.children.length;
|
||||
const row = document.createElement('div');
|
||||
row.className = 'sub-form-row';
|
||||
let options = '<option value="">(Rien)</option>';
|
||||
resourcesList.forEach(r => {
|
||||
options += `<option value="${r.slug}" ${slug === r.slug ? 'selected' : ''}>${r.name}</option>`;
|
||||
});
|
||||
|
||||
row.innerHTML = `
|
||||
<div class="toggle-container">
|
||||
<label class="switch">
|
||||
<input type="hidden" name="item_is_guaranteed[${rowIdx}]" value="0">
|
||||
<input type="checkbox" name="item_is_guaranteed[${rowIdx}]" value="1" ${isGuaranteed ? 'checked' : ''} onchange="toggleItemType(this)">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
<span class="type-label" style="color: ${isGuaranteed ? '#a3be8c' : '#8c92a3'}">${isGuaranteed ? 'DIRECT' : 'POULE'}</span>
|
||||
</div>
|
||||
<select name="item_slug[${rowIdx}]" style="flex: 2;">${options}</select>
|
||||
<input type="number" name="item_prob[${rowIdx}]" value="${prob}" class="item-prob-input" style="flex: 1; ${isGuaranteed ? 'visibility:hidden' : ''}" placeholder="Prob %" step="0.01">
|
||||
<input type="number" name="item_qmin[${rowIdx}]" value="${qmin}" style="flex: 0 0 70px;" placeholder="Min">
|
||||
<input type="number" name="item_qmax[${rowIdx}]" value="${qmax}" style="flex: 0 0 70px;" placeholder="Max">
|
||||
<div class="btn-del-row" onclick="this.parentElement.remove()">×</div>
|
||||
`;
|
||||
container.appendChild(row);
|
||||
}
|
||||
|
||||
function editLootbox(data) {
|
||||
document.getElementById('lb_id').value = data.id;
|
||||
document.getElementById('lb_name').value = data.name;
|
||||
document.getElementById('lb_slug').value = data.slug;
|
||||
document.getElementById('lb_desc').value = data.description || '';
|
||||
|
||||
document.getElementById('rolls_container').innerHTML = '';
|
||||
if (data.rolls && data.rolls.length > 0) {
|
||||
data.rolls.forEach(r => addRollRow(r.roll_count, r.probability));
|
||||
} else {
|
||||
addRollRow();
|
||||
}
|
||||
|
||||
document.getElementById('items_container').innerHTML = '';
|
||||
if (data.items && data.items.length > 0) {
|
||||
data.items.forEach((i, idx) => addItemRow(i.resource_slug, i.probability, i.quantity_min, i.quantity_max, i.is_guaranteed));
|
||||
} else {
|
||||
addItemRow();
|
||||
}
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
|
||||
function resetLootboxForm() {
|
||||
document.getElementById('lootboxForm').reset();
|
||||
document.getElementById('lb_id').value = 0;
|
||||
document.getElementById('rolls_container').innerHTML = '';
|
||||
document.getElementById('items_container').innerHTML = '';
|
||||
addRollRow();
|
||||
addItemRow();
|
||||
}
|
||||
|
||||
<?php if ($tab === 'lootboxes'): ?>
|
||||
window.onload = function() {
|
||||
if (document.getElementById('rolls_container').children.length === 0) addRollRow();
|
||||
if (document.getElementById('items_container').children.length === 0) addItemRow();
|
||||
};
|
||||
<?php endif; ?>
|
||||
|
||||
function toggleMS(id) {
|
||||
const d = document.getElementById(id);
|
||||
d.style.display = d.style.display === 'block' ? 'none' : 'block';
|
||||
}
|
||||
function updateMSLabel(containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
const checkboxes = container.querySelectorAll('input[type="checkbox"]:checked');
|
||||
const display = container.querySelector('.ms-display');
|
||||
if (checkboxes.length === 0) {
|
||||
display.innerText = "Toutes / Peu importe";
|
||||
} else {
|
||||
const labels = Array.from(checkboxes).map(cb => cb.parentElement.innerText.trim());
|
||||
display.innerText = labels.join(', ');
|
||||
}
|
||||
}
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!e.target.closest('.ms-container')) {
|
||||
document.querySelectorAll('.ms-dropdown').forEach(d => d.style.display = 'none');
|
||||
}
|
||||
});
|
||||
|
||||
function editLevel(data) {
|
||||
document.getElementById("level_id").value = data.id;
|
||||
document.getElementById("level_name").value = data.name;
|
||||
document.getElementById("level_slug").value = data.slug;
|
||||
document.getElementById("level_resource_id").value = data.resource_id;
|
||||
document.getElementById("level_required_quantity").value = data.required_quantity;
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
function resetLevelForm() {
|
||||
document.getElementById("levelForm").reset();
|
||||
document.getElementById("level_id").value = 0;
|
||||
const select = document.getElementById("level_resource_id");
|
||||
for (let i = 0; i < select.options.length; i++) {
|
||||
if (select.options[i].text.toLowerCase().includes("expérience") || select.options[i].text.toLowerCase().includes("experience")) {
|
||||
select.selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateRankFields() {
|
||||
const type = document.getElementById('rank_type').value;
|
||||
const min = document.getElementById('rank_min');
|
||||
const max = document.getElementById('rank_max');
|
||||
if (type === 'utilisateur') {
|
||||
min.disabled = false;
|
||||
max.disabled = false;
|
||||
min.required = true;
|
||||
max.required = true;
|
||||
min.style.opacity = '1';
|
||||
max.style.opacity = '1';
|
||||
} else {
|
||||
min.disabled = true;
|
||||
max.disabled = true;
|
||||
min.required = false;
|
||||
max.required = false;
|
||||
min.style.opacity = '0.5';
|
||||
max.style.opacity = '0.5';
|
||||
min.value = '';
|
||||
max.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function editRank(rank) {
|
||||
document.getElementById('rank_id').value = rank.id;
|
||||
document.getElementById('rank_name').value = rank.name;
|
||||
document.getElementById('rank_slug').value = rank.slug;
|
||||
document.getElementById('rank_type').value = rank.user_type;
|
||||
document.getElementById('rank_min').value = rank.min_level || '';
|
||||
document.getElementById('rank_max').value = rank.max_level || '';
|
||||
updateRankFields();
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
|
||||
function resetRankForm() {
|
||||
document.getElementById('rankForm').reset();
|
||||
document.getElementById('rank_id').value = '0';
|
||||
updateRankFields();
|
||||
}
|
||||
|
||||
// Initial call to set fields on load
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
if (document.getElementById('rank_type')) {
|
||||
updateRankFields();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -12,12 +12,20 @@ $pdo->exec("CREATE TABLE IF NOT EXISTS guilds (
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS guild_creation_requirements (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
resource_id INT NOT NULL,
|
||||
quantity INT NOT NULL,
|
||||
amount INT NOT NULL,
|
||||
FOREIGN KEY (resource_id) REFERENCES game_resources(id)
|
||||
)");
|
||||
|
||||
// Vérifier si la table guild_restrictions existe déjà et ajouter la colonne si nécessaire
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS guild_restrictions (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
restriction_key VARCHAR(255) NOT NULL,
|
||||
restriction_value TEXT
|
||||
restriction_key VARCHAR(255) NOT NULL UNIQUE,
|
||||
value VARCHAR(255) NOT NULL,
|
||||
description TEXT
|
||||
)");
|
||||
|
||||
// Migration pour ajouter member_limit si elle n'existe pas
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM guild_restrictions WHERE restriction_key = 'member_limit'");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$pdo->exec("INSERT INTO guild_restrictions (restriction_key, value, description) VALUES ('member_limit', '50', 'Nombre maximum de membres par guilde')");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user