323 lines
13 KiB
PHP
323 lines
13 KiB
PHP
<?php
|
||
|
||
require_once __DIR__ . '/db/auth.php';
|
||
require_once __DIR__ . '/db/scstatsitem.php';
|
||
require_once __DIR__ . '/db/scitemcustom.php';
|
||
require_once __DIR__ . '/db/scmanutention.php';
|
||
|
||
auth_start_session();
|
||
auth_bootstrap();
|
||
scstatsitem_bootstrap();
|
||
scitemcustom_bootstrap();
|
||
scmanutention_bootstrap();
|
||
|
||
function scmanutentionpublic_item_name(array $item_row): string
|
||
{
|
||
return (string) ((($item_row['cl_scmanutentionitem_source'] ?? '') === 'custom')
|
||
? ($item_row['cl_scmanutentionitem_custom_name'] ?? '')
|
||
: ($item_row['cl_scmanutentionitem_base_name'] ?? ''));
|
||
}
|
||
|
||
function scmanutentionpublic_item_type(array $item_row): string
|
||
{
|
||
return (string) ((($item_row['cl_scmanutentionitem_source'] ?? '') === 'custom')
|
||
? ($item_row['cl_scmanutentionitem_custom_type'] ?? '')
|
||
: ($item_row['cl_scmanutentionitem_base_type'] ?? ''));
|
||
}
|
||
|
||
function scmanutentionpublic_item_subtype(array $item_row): string
|
||
{
|
||
return (string) ((($item_row['cl_scmanutentionitem_source'] ?? '') === 'custom')
|
||
? ($item_row['cl_scmanutentionitem_custom_subtype'] ?? '')
|
||
: ($item_row['cl_scmanutentionitem_base_subtype'] ?? ''));
|
||
}
|
||
|
||
function scmanutentionpublic_item_uuid(array $item_row): string
|
||
{
|
||
return (string) ((($item_row['cl_scmanutentionitem_source'] ?? '') === 'custom')
|
||
? ($item_row['cl_scmanutentionitem_custom_uuid'] ?? '')
|
||
: ($item_row['cl_scmanutentionitem_base_uuid'] ?? ''));
|
||
}
|
||
|
||
function scmanutentionpublic_item_rarity(array $item_row): string
|
||
{
|
||
return (string) ((($item_row['cl_scmanutentionitem_source'] ?? '') === 'custom')
|
||
? ($item_row['cl_scmanutentionitem_custom_rarity'] ?? '')
|
||
: ($item_row['cl_scmanutentionitem_base_rarity'] ?? ''));
|
||
}
|
||
|
||
function scmanutentionpublic_rarity_class(string $rarity): string
|
||
{
|
||
$rarity = strtoupper(trim($rarity));
|
||
|
||
return in_array($rarity, ['L', 'E', 'R', 'U', 'C'], true) ? 'rarity-' . $rarity : '';
|
||
}
|
||
|
||
function scmanutentionpublic_stat_preview(array $stat_row): string
|
||
{
|
||
$sign = (string) ($stat_row['cl_scitemcustomstat_sign'] ?? '');
|
||
$prefix = $sign === '-' ? '-' : ($sign === '+' ? '+' : '');
|
||
$value = number_format((float) ($stat_row['cl_scitemcustomstat_value'] ?? 0), 2, '.', '');
|
||
$value = rtrim(rtrim($value, '0'), '.');
|
||
if ($value === '') {
|
||
$value = '0';
|
||
}
|
||
|
||
$unit = trim((string) ($stat_row['cl_scstatsitem_unit'] ?? ''));
|
||
|
||
return trim((string) ($stat_row['cl_scstatsitem_name'] ?? '') . ' : ' . $prefix . $value . ($unit !== '' ? ' ' . $unit : ''));
|
||
}
|
||
|
||
$db = db();
|
||
$share_token = trim((string) ($_GET['share'] ?? ''));
|
||
$sheet = scmanutention_find_public_sheet_by_token($db, $share_token);
|
||
$items = $sheet ? scmanutention_fetch_items($db, (int) $sheet['cl_scmanutention_id']) : [];
|
||
$custom_stats_map = scmanutention_fetch_custom_stats_map($db, $items);
|
||
|
||
if (!$sheet) {
|
||
http_response_code(404);
|
||
}
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="fr">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title><?php echo htmlspecialchars($sheet ? ((string) $sheet['cl_scmanutention_title'] . ' | Fiche manutention') : 'Fiche introuvable', ENT_QUOTES, 'UTF-8'); ?></title>
|
||
<style>
|
||
:root {
|
||
--primary: #a29b78;
|
||
--primary-soft: rgba(162, 155, 120, 0.18);
|
||
--primary-border: rgba(162, 155, 120, 0.34);
|
||
--bg: #07090d;
|
||
--surface: rgba(15, 19, 28, 0.88);
|
||
--surface-soft: rgba(255,255,255,0.05);
|
||
--surface-border: rgba(255,255,255,0.08);
|
||
--text-main: #f2efe4;
|
||
--text-soft: rgba(242, 239, 228, 0.72);
|
||
--rarity-L: #ff8000;
|
||
--rarity-E: #a335ee;
|
||
--rarity-R: #0070dd;
|
||
--rarity-U: #1eff00;
|
||
--rarity-C: #ffffff;
|
||
}
|
||
|
||
* { box-sizing: border-box; }
|
||
|
||
body {
|
||
margin: 0;
|
||
min-height: 100vh;
|
||
background:
|
||
linear-gradient(rgba(6, 8, 12, 0.8), rgba(6, 8, 12, 0.92)),
|
||
url('https://robertsspaceindustries.com/media/1vllgn95062syr/background_blur/REACT-Background.jpg') center/cover fixed;
|
||
color: var(--text-main);
|
||
font-family: Arial, Helvetica, sans-serif;
|
||
}
|
||
|
||
.page {
|
||
width: min(1180px, calc(100vw - 2rem));
|
||
margin: 0 auto;
|
||
padding: 2rem 0 3rem;
|
||
}
|
||
|
||
.hero,
|
||
.panel,
|
||
.item-card,
|
||
.message {
|
||
background: var(--surface);
|
||
border: 1px solid var(--primary-border);
|
||
border-radius: 22px;
|
||
box-shadow: 0 22px 46px rgba(0,0,0,0.32);
|
||
backdrop-filter: blur(12px);
|
||
}
|
||
|
||
.hero,
|
||
.panel,
|
||
.message {
|
||
padding: 1.2rem;
|
||
margin-bottom: 1rem;
|
||
}
|
||
|
||
h1, h2 { margin-top: 0; }
|
||
p { line-height: 1.6; }
|
||
|
||
.meta,
|
||
.item-meta,
|
||
.stats-list {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 0.5rem;
|
||
align-items: center;
|
||
}
|
||
|
||
.badge {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 0.34rem 0.62rem;
|
||
border-radius: 999px;
|
||
background: rgba(255,255,255,0.06);
|
||
border: 1px solid rgba(255,255,255,0.1);
|
||
color: var(--text-soft);
|
||
font-size: 0.82rem;
|
||
}
|
||
|
||
.items-list {
|
||
display: grid;
|
||
gap: 0.9rem;
|
||
}
|
||
|
||
.item-card {
|
||
padding: 0.95rem;
|
||
display: grid;
|
||
gap: 0.7rem;
|
||
}
|
||
|
||
.item-head {
|
||
display: flex;
|
||
gap: 0.85rem;
|
||
align-items: start;
|
||
}
|
||
|
||
.item-title-line {
|
||
display: flex;
|
||
align-items: baseline;
|
||
gap: 0.45rem;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.item-quantity-prefix {
|
||
font-weight: 800;
|
||
color: #fff2ca;
|
||
letter-spacing: 0.02em;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.item-preview {
|
||
width: 56px;
|
||
height: 56px;
|
||
object-fit: cover;
|
||
border-radius: 14px;
|
||
background: rgba(255,255,255,0.06);
|
||
border: 1px solid rgba(255,255,255,0.08);
|
||
flex: none;
|
||
}
|
||
|
||
.item-text { min-width: 0; display: grid; gap: 5px; }
|
||
.item-name { font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
|
||
.helper, .muted { color: var(--text-soft); }
|
||
.item-extra {
|
||
padding: 0.72rem 0.85rem;
|
||
border-radius: 14px;
|
||
background: rgba(255,255,255,0.04);
|
||
border: 1px solid rgba(255,255,255,0.08);
|
||
}
|
||
|
||
.stat-pill {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
min-height: 30px;
|
||
padding: 0.38rem 0.72rem;
|
||
border-radius: 12px;
|
||
background: linear-gradient(135deg, rgba(26, 74, 42, 0.9), rgba(18, 46, 28, 0.82));
|
||
border: 1px solid rgba(90, 255, 150, 0.85);
|
||
box-shadow: inset 0 0 0 1px rgba(140, 255, 188, 0.18), 0 0 0 1px rgba(34, 110, 58, 0.28), 0 10px 22px rgba(0,0,0,0.18);
|
||
font-size: 0.8rem;
|
||
font-weight: 700;
|
||
color: #dcffe9;
|
||
}
|
||
|
||
.rarity-L { color: var(--rarity-L); text-shadow: 0 0 12px rgba(255, 128, 0, 0.28); }
|
||
.rarity-E { color: var(--rarity-E); text-shadow: 0 0 12px rgba(163, 53, 238, 0.28); }
|
||
.rarity-R { color: var(--rarity-R); text-shadow: 0 0 12px rgba(0, 112, 221, 0.28); }
|
||
.rarity-U { color: var(--rarity-U); text-shadow: 0 0 12px rgba(30, 255, 0, 0.28); }
|
||
.rarity-C { color: var(--rarity-C); }
|
||
|
||
@media (max-width: 700px) {
|
||
.page { width: min(100%, calc(100vw - 1rem)); }
|
||
.item-head { flex-wrap: wrap; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="page">
|
||
<?php if (!$sheet): ?>
|
||
<section class="message">
|
||
<h1>Fiche introuvable</h1>
|
||
<p>Cette fiche n’existe pas, n’est plus publique, ou le lien partagé n’est plus valide.</p>
|
||
</section>
|
||
<?php else: ?>
|
||
<section class="hero">
|
||
<h1><?php echo htmlspecialchars((string) $sheet['cl_scmanutention_title'], ENT_QUOTES, 'UTF-8'); ?></h1>
|
||
<div class="meta">
|
||
<?php if (!empty($sheet['cl_scmanutention_type'])): ?>
|
||
<span class="badge"><?php echo htmlspecialchars((string) $sheet['cl_scmanutention_type'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||
<?php endif; ?>
|
||
<?php if (!empty($sheet['cl_scmanutention_subtype'])): ?>
|
||
<span class="badge"><?php echo htmlspecialchars((string) $sheet['cl_scmanutention_subtype'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||
<?php endif; ?>
|
||
<span class="badge"><?php echo count($items); ?> objet(s)</span>
|
||
<span class="badge">Publié par <?php echo htmlspecialchars((string) ($sheet['cl_scmanutention_owner_name'] ?? 'Inconnu'), ENT_QUOTES, 'UTF-8'); ?></span>
|
||
</div>
|
||
<?php if (!empty($sheet['cl_scmanutention_description'])): ?>
|
||
<p><?php echo nl2br(htmlspecialchars((string) $sheet['cl_scmanutention_description'], ENT_QUOTES, 'UTF-8')); ?></p>
|
||
<?php else: ?>
|
||
<p class="helper">Cette fiche publique ne contient pas encore de description.</p>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<section class="panel">
|
||
<h2>Contenu de la fiche</h2>
|
||
<?php if (empty($items)): ?>
|
||
<p class="muted">Aucun objet n’est actuellement listé sur cette fiche.</p>
|
||
<?php else: ?>
|
||
<div class="items-list">
|
||
<?php foreach ($items as $item_row): ?>
|
||
<?php
|
||
$item_name = scmanutentionpublic_item_name($item_row);
|
||
$item_type = scmanutentionpublic_item_type($item_row);
|
||
$item_subtype = scmanutentionpublic_item_subtype($item_row);
|
||
$item_uuid = scmanutentionpublic_item_uuid($item_row);
|
||
$item_rarity_class = scmanutentionpublic_rarity_class(scmanutentionpublic_item_rarity($item_row));
|
||
$item_source = (string) ($item_row['cl_scmanutentionitem_source'] ?? 'base');
|
||
$item_custom_id = (int) ($item_row['cl_scmanutentionitem_scitemcustom_id'] ?? 0);
|
||
$item_stats = $item_source === 'custom' ? ($custom_stats_map[$item_custom_id] ?? []) : [];
|
||
?>
|
||
<article class="item-card">
|
||
<div class="item-head">
|
||
<?php if ($item_uuid !== ''): ?>
|
||
<img src="https://cstone.space/uifimages/<?php echo htmlspecialchars($item_uuid, ENT_QUOTES, 'UTF-8'); ?>.png" alt="" class="item-preview">
|
||
<?php endif; ?>
|
||
<div class="item-text">
|
||
<div class="item-title-line">
|
||
<span class="item-quantity-prefix"><?php echo (int) ($item_row['cl_scmanutentionitem_quantity'] ?? 1); ?>x</span>
|
||
<div class="item-name <?php echo htmlspecialchars($item_rarity_class, ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($item_name, ENT_QUOTES, 'UTF-8'); ?></div>
|
||
</div>
|
||
<div class="item-meta">
|
||
<span class="badge"><?php echo htmlspecialchars($item_type !== '' ? $item_type : 'Sans type', ENT_QUOTES, 'UTF-8'); ?></span>
|
||
<?php if ($item_subtype !== ''): ?>
|
||
<span class="badge"><?php echo htmlspecialchars($item_subtype, ENT_QUOTES, 'UTF-8'); ?></span>
|
||
<?php endif; ?>
|
||
<span class="badge"><?php echo $item_source === 'custom' ? 'Objet perso' : 'Base d\'objets'; ?></span>
|
||
<?php if (!empty($item_stats)): ?>
|
||
<?php foreach ($item_stats as $stat_row): ?>
|
||
<span class="stat-pill"><?php echo htmlspecialchars(scmanutentionpublic_stat_preview($stat_row), ENT_QUOTES, 'UTF-8'); ?></span>
|
||
<?php endforeach; ?>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<?php if (!empty($item_row['cl_scmanutentionitem_extra_info'])): ?>
|
||
<div class="item-extra"><?php echo nl2br(htmlspecialchars((string) $item_row['cl_scmanutentionitem_extra_info'], ENT_QUOTES, 'UTF-8')); ?></div>
|
||
<?php endif; ?>
|
||
|
||
</article>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
</section>
|
||
<?php endif; ?>
|
||
</div>
|
||
</body>
|
||
</html>
|