Autosave: 20260408-021238
This commit is contained in:
parent
5e60c40234
commit
cb61082775
287
scitems.php
287
scitems.php
@ -57,16 +57,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$count_updated = 0;
|
||||
|
||||
$stmt_check = $db->prepare("SELECT cl_scobjs_id FROM tbl_scobjs WHERE cl_scobjs_uuid = :uuid");
|
||||
$stmt_insert = $db->prepare("INSERT INTO tbl_scobjs (cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity, cl_scobjs_about) VALUES (:name, :type, :subtype, :uuid, '', '')");
|
||||
$stmt_update = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_name = :name, cl_scobjs_type = :type, cl_scobjs_subtype = :subtype WHERE cl_scobjs_uuid = :uuid");
|
||||
$stmt_insert = $db->prepare("INSERT INTO tbl_scobjs (cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity, cl_scobjs_about) VALUES (:name, :type, :subtype, :uuid, '', :about)");
|
||||
$stmt_update = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_name = :name, cl_scobjs_type = :type, cl_scobjs_subtype = :subtype, cl_scobjs_about = :about WHERE cl_scobjs_uuid = :uuid");
|
||||
|
||||
foreach ($items as $item) {
|
||||
$uuid = $item['reference'] ?? ($item['stdItem']['UUID'] ?? '');
|
||||
if (!$uuid) continue;
|
||||
|
||||
$name = $item['stdItem']['Name'] ?? '';
|
||||
$manufacturer = $item['manufacturer'] ?? ($item['stdItem']['Manufacturer']['Code'] ?? '');
|
||||
$raw_name = $item['stdItem']['Name'] ?? '';
|
||||
$name = ($manufacturer && strpos($raw_name, $manufacturer) === false) ? "[$manufacturer] $raw_name" : $raw_name;
|
||||
|
||||
$type = $item['type'] ?? '';
|
||||
$subtype = $item['subType'] ?? '';
|
||||
$about = $item['stdItem']['Description'] ?? '';
|
||||
|
||||
$stmt_check->execute(['uuid' => $uuid]);
|
||||
if ($stmt_check->fetch()) {
|
||||
@ -74,6 +78,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'about' => $about,
|
||||
'uuid' => $uuid
|
||||
]);
|
||||
$count_updated++;
|
||||
@ -82,7 +87,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'uuid' => $uuid
|
||||
'uuid' => $uuid,
|
||||
'about' => $about
|
||||
]);
|
||||
$count_new++;
|
||||
}
|
||||
@ -102,140 +108,93 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$stmt = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_rarity = :rarity, cl_scobjs_about = :about WHERE cl_scobjs_id = :id");
|
||||
$stmt->execute(['rarity' => $rarity, 'about' => $about, 'id' => $id]);
|
||||
|
||||
auth_flash_set('success', "Objet mis à jour avec succès.");
|
||||
auth_flash_set('success', 'Objet mis à jour.');
|
||||
header('Location: scitems.php?page=' . $page . '&search=' . urlencode($search));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch items
|
||||
$sql_count = "SELECT COUNT(*) FROM tbl_scobjs WHERE $where";
|
||||
$stmt_count = $db->prepare($sql_count);
|
||||
// Fetch data
|
||||
$stmt_count = $db->prepare("SELECT COUNT(*) FROM tbl_scobjs WHERE $where");
|
||||
$stmt_count->execute($params);
|
||||
$total_items = (int)$stmt_count->fetchColumn();
|
||||
$total_items = $stmt_count->fetchColumn();
|
||||
$total_pages = ceil($total_items / $limit);
|
||||
|
||||
$sql_items = "SELECT * FROM tbl_scobjs WHERE $where ORDER BY cl_scobjs_name ASC LIMIT $limit OFFSET $offset";
|
||||
$stmt_items = $db->prepare($sql_items);
|
||||
$stmt_items->execute($params);
|
||||
$items_list = $stmt_items->fetchAll();
|
||||
$stmt_list = $db->prepare("SELECT * FROM tbl_scobjs WHERE $where ORDER BY cl_scobjs_id DESC LIMIT $limit OFFSET $offset");
|
||||
$stmt_list->execute($params);
|
||||
$items_list = $stmt_list->fetchAll();
|
||||
|
||||
$current_session_user = $_SESSION['user'] ?? '';
|
||||
$edit_id = isset($_GET['edit']) ? (int)$_GET['edit'] : 0;
|
||||
$edit_item = null;
|
||||
if ($edit_id > 0) {
|
||||
if (isset($_GET['edit'])) {
|
||||
$stmt_edit = $db->prepare("SELECT * FROM tbl_scobjs WHERE cl_scobjs_id = :id");
|
||||
$stmt_edit->execute(['id' => $edit_id]);
|
||||
$stmt_edit->execute(['id' => (int)$_GET['edit']]);
|
||||
$edit_item = $stmt_edit->fetch();
|
||||
}
|
||||
|
||||
$current_session_user = $_SESSION['user_name'] ?? 'Admin';
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Gestion des Objets | R.E.A.C.T. Admin</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/styles.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/default.css">
|
||||
<title>Admin - Base d'Objets</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Electrolize&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
<style>
|
||||
:root {
|
||||
--primary: #a29b78;
|
||||
--primary-glow: rgba(162, 155, 120, 0.4);
|
||||
--bg-dark: #080a0f;
|
||||
--card-bg: rgba(20, 24, 33, 0.85);
|
||||
--border-glow: rgba(162, 155, 120, 0.25);
|
||||
--primary-glow: rgba(162, 155, 120, 0.3);
|
||||
--bg-dark: #0a0b0d;
|
||||
--card-bg: rgba(20, 22, 26, 0.8);
|
||||
--border-glow: rgba(162, 155, 120, 0.2);
|
||||
--rarity-L: #ff8000;
|
||||
--rarity-E: #a335ee;
|
||||
--rarity-R: #0070dd;
|
||||
--rarity-U: #1eff00;
|
||||
--rarity-C: #ffffff;
|
||||
--danger: #ff4d4d;
|
||||
--success: #00ff88;
|
||||
|
||||
/* Rarity Colors */
|
||||
--rarity-L: #ff8000; /* Legendary - Orange */
|
||||
--rarity-E: #a335ee; /* Epic - Purple */
|
||||
--rarity-R: #0070dd; /* Rare - Blue */
|
||||
--rarity-U: #1eff00; /* Uncommon - Green */
|
||||
--rarity-C: #ffffff; /* Common - White */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Electrolize';
|
||||
src: url('fonts/Electrolize-Regular.ttf') format('truetype');
|
||||
}
|
||||
|
||||
body {
|
||||
background: radial-gradient(circle at top right, #1a1f2e, var(--bg-dark));
|
||||
background-attachment: fixed;
|
||||
background: var(--bg-dark);
|
||||
color: #e0e0e0;
|
||||
font-family: 'Electrolize', sans-serif;
|
||||
margin: 0;
|
||||
overflow-x: hidden;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.admin-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
animation: fadeIn 0.6s ease-out;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
line-height: 1.6;
|
||||
background-image:
|
||||
radial-gradient(circle at 50% 50%, rgba(162, 155, 120, 0.05) 0%, transparent 50%),
|
||||
linear-gradient(rgba(10, 11, 13, 0.9), rgba(10, 11, 13, 0.9));
|
||||
}
|
||||
|
||||
.admin-layout { max-width: 1400px; margin: 0 auto; padding: 2rem; }
|
||||
|
||||
.admin-topbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1.5rem 2rem;
|
||||
background: var(--card-bg);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid var(--border-glow);
|
||||
border-radius: 12px;
|
||||
margin-bottom: 2rem;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid var(--border-glow);
|
||||
}
|
||||
|
||||
.topbar-info h1 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
background: linear-gradient(90deg, #fff, var(--primary));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.topbar-info p {
|
||||
margin: 0.25rem 0 0;
|
||||
font-size: 0.85rem;
|
||||
color: var(--primary);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.topbar-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
.topbar-info h1 { margin: 0; font-size: 1.5rem; color: var(--primary); text-transform: uppercase; letter-spacing: 2px; }
|
||||
.topbar-info p { margin: 5px 0 0; font-size: 0.8rem; opacity: 0.7; }
|
||||
|
||||
.btn-modern {
|
||||
padding: 0.6rem 1.2rem;
|
||||
background: rgba(162, 155, 120, 0.1);
|
||||
border: 1px solid var(--primary);
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
font-family: 'Electrolize', sans-serif;
|
||||
font-size: 0.9rem;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
color: var(--primary);
|
||||
padding: 0.6rem 1.2rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.8rem;
|
||||
letter-spacing: 1px;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.btn-modern:hover {
|
||||
@ -247,57 +206,33 @@ if ($edit_id > 0) {
|
||||
.btn-modern.danger { border-color: var(--danger); color: var(--danger); }
|
||||
.btn-modern.danger:hover { background: var(--danger); color: #fff; }
|
||||
|
||||
.admin-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 3fr;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.admin-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
||||
.glass-card {
|
||||
background: var(--card-bg);
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--border-glow);
|
||||
border-radius: 12px;
|
||||
padding: 2rem;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
||||
height: fit-content;
|
||||
padding: 1.5rem;
|
||||
backdrop-filter: blur(10px);
|
||||
box-shadow: 0 8px 32px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.glass-card h2 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 1.25rem;
|
||||
color: var(--primary);
|
||||
border-bottom: 1px solid var(--border-glow);
|
||||
padding-bottom: 0.75rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.admin-grid { display: grid; grid-template-columns: 350px 1fr; gap: 2rem; }
|
||||
|
||||
.form-group { margin-bottom: 1.5rem; }
|
||||
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: #aaa; text-transform: uppercase; }
|
||||
.form-group { margin-bottom: 1.2rem; }
|
||||
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--primary); text-transform: uppercase; }
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 0.8rem 1rem;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border: 1px solid #444;
|
||||
background: rgba(0,0,0,0.3);
|
||||
border: 1px solid var(--border-glow);
|
||||
border-radius: 4px;
|
||||
padding: 0.8rem;
|
||||
color: #fff;
|
||||
font-family: 'Electrolize', sans-serif;
|
||||
transition: border-color 0.3s;
|
||||
font-family: inherit;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.form-control:focus { outline: none; border-color: var(--primary); background: rgba(0, 0, 0, 0.5); }
|
||||
|
||||
.modern-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
|
||||
.modern-table th { text-align: left; padding: 1rem; font-size: 0.8rem; text-transform: uppercase; color: var(--primary); opacity: 0.7; }
|
||||
.modern-table td { padding: 1rem; background: rgba(255, 255, 255, 0.03); border-top: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: top; }
|
||||
.modern-table td:first-child { border-left: 1px solid rgba(255, 255, 255, 0.05); border-radius: 8px 0 0 8px; }
|
||||
.modern-table td:last-child { border-right: 1px solid rgba(255, 255, 255, 0.05); border-radius: 0 8px 8px 0; }
|
||||
.modern-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
|
||||
.modern-table th { text-align: left; padding: 1rem; border-bottom: 2px solid var(--border-glow); color: var(--primary); font-size: 0.8rem; text-transform: uppercase; }
|
||||
.modern-table td { padding: 1rem; border-bottom: 1px solid rgba(162, 155, 120, 0.1); vertical-align: top; }
|
||||
.modern-table tr:hover td { background: rgba(162, 155, 120, 0.05); }
|
||||
|
||||
.flash { padding: 1rem 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; font-size: 0.9rem; border-left: 4px solid var(--primary); background: rgba(162, 155, 120, 0.1); }
|
||||
@ -324,7 +259,7 @@ if ($edit_id > 0) {
|
||||
.item-name { color: var(--primary); font-weight: bold; display: block; font-size: 1rem; margin-bottom: 4px; }
|
||||
.item-meta { font-size: 0.75rem; color: #888; display: block; }
|
||||
.item-uuid { font-size: 0.75rem; color: #777; font-family: monospace; word-break: break-all; display: block; margin-bottom: 4px; }
|
||||
.item-about-cell { font-size: 0.85rem; color: #ccc; line-height: 1.4; }
|
||||
.item-about-cell { font-size: 0.85rem; color: #ccc; line-height: 1.4; white-space: pre-line; }
|
||||
|
||||
/* Preview System */
|
||||
.preview-container {
|
||||
@ -500,37 +435,39 @@ if ($edit_id > 0) {
|
||||
<tr><td colspan="4" style="text-align: center; padding: 3rem; color: #666;">Aucun objet trouvé.</td></tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($items_list as $item): ?>
|
||||
<?php
|
||||
$rarityClass = '';
|
||||
if ($item['cl_scobjs_rarity']) {
|
||||
$rarityClass = 'rarity-' . $item['cl_scobjs_rarity'];
|
||||
}
|
||||
$imageUrl = "https://cstone.space/uifimages/" . $item['cl_scobjs_uuid'] . ".png";
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="preview-container">
|
||||
<img src="<?php echo $imageUrl; ?>" class="item-preview" alt="" loading="lazy">
|
||||
<div class="preview-floating">
|
||||
<img src="<?php echo $imageUrl; ?>" alt="">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="preview-container">
|
||||
<img src="https://sc-item-icons.s3.amazonaws.com/<?php echo $item['cl_scobjs_uuid']; ?>.png"
|
||||
class="item-preview"
|
||||
onerror="this.src='img/icon10.png';"
|
||||
alt="">
|
||||
<div class="preview-floating">
|
||||
<img src="https://sc-item-icons.s3.amazonaws.com/<?php echo $item['cl_scobjs_uuid']; ?>.png"
|
||||
onerror="this.src='img/icon10.png';"
|
||||
alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="item-name <?php echo $rarityClass; ?>"><?php echo htmlspecialchars($item['cl_scobjs_name']); ?></span>
|
||||
<span class="item-uuid"><?php echo htmlspecialchars($item['cl_scobjs_uuid']); ?></span>
|
||||
<span class="item-meta">
|
||||
<?php echo htmlspecialchars($item['cl_scobjs_type']); ?>
|
||||
<?php if($item['cl_scobjs_subtype']) echo " / " . htmlspecialchars($item['cl_scobjs_subtype']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="item-about-cell">
|
||||
<?php echo nl2br(htmlspecialchars($item['cl_scobjs_about'])); ?>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<a href="scitems.php?edit=<?php echo $item['cl_scobjs_id']; ?>&page=<?php echo $page; ?>&search=<?php echo urlencode($search); ?>" class="btn-modern btn-mini">Editer</a>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
<td>
|
||||
<span class="item-name <?php echo $item['cl_scobjs_rarity'] ? 'rarity-'.$item['cl_scobjs_rarity'] : ''; ?>">
|
||||
<?php echo htmlspecialchars($item['cl_scobjs_name']); ?>
|
||||
</span>
|
||||
<span class="item-uuid"><?php echo htmlspecialchars($item['cl_scobjs_uuid']); ?></span>
|
||||
<span class="item-meta">
|
||||
<span class="badge"><?php echo htmlspecialchars($item['cl_scobjs_type']); ?></span>
|
||||
<?php if ($item['cl_scobjs_subtype']): ?>
|
||||
<span class="badge" style="background: rgba(162,155,120,0.1);"><?php echo htmlspecialchars($item['cl_scobjs_subtype']); ?></span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="item-about-cell">
|
||||
<?php echo htmlspecialchars($item['cl_scobjs_about']); ?>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<a href="scitems.php?edit=<?php echo $item['cl_scobjs_id']; ?>&page=<?php echo $page; ?>&search=<?php echo urlencode($search); ?>" class="btn-modern" style="padding: 0.4rem 0.8rem;">Edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
@ -538,17 +475,25 @@ if ($edit_id > 0) {
|
||||
</div>
|
||||
|
||||
<?php if ($total_pages > 1): ?>
|
||||
<div class="pagination">
|
||||
<?php for ($i = 1; $i <= $total_pages; $i++): ?>
|
||||
<?php if ($i == 1 || $i == $total_pages || ($i >= $page - 2 && $i <= $page + 2)): ?>
|
||||
<a href="scitems.php?page=<?php echo $i; ?>&search=<?php echo urlencode($search); ?>" class="page-link <?php echo $i == $page ? 'active' : ''; ?>">
|
||||
<div class="pagination">
|
||||
<?php if ($page > 1): ?>
|
||||
<a href="scitems.php?page=<?php echo $page - 1; ?>&search=<?php echo urlencode($search); ?>" class="page-link">«</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$start_page = max(1, $page - 2);
|
||||
$end_page = min($total_pages, $page + 2);
|
||||
for ($i = $start_page; $i <= $end_page; $i++):
|
||||
?>
|
||||
<a href="scitems.php?page=<?php echo $i; ?>&search=<?php echo urlencode($search); ?>" class="page-link <?php echo $i === $page ? 'active' : ''; ?>">
|
||||
<?php echo $i; ?>
|
||||
</a>
|
||||
<?php elseif ($i == $page - 3 || $i == $page + 3): ?>
|
||||
<span style="padding: 0.5rem;">...</span>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if ($page < $total_pages): ?>
|
||||
<a href="scitems.php?page=<?php echo $page + 1; ?>&search=<?php echo urlencode($search); ?>" class="page-link">»</a>
|
||||
<?php endif; ?>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user