Initial import of fitme3070.pt platform
Plain-PHP fleet platform with id.andmore.pt SSO. Wires shared/platform-tools as a submodule (platform_update, backups, git/migration tools) like the other platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
e68d357177
2330 files changed
+215968
No files matched your search
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../../config/db.php';
|
||||
require __DIR__ . '/../../../config/functions.php';
|
||||
$user = ["id"=>1,"name"=>"Teste","email"=>"teste@fitme3070.pt","role"=>"sysadmin"]; $_SESSION["user_id"] = 1; $_SESSION["user"] = $user; // require_admin();
|
||||
|
||||
$id = (int) ($_GET['id'] ?? 0);
|
||||
if (!$id) { header('Location: index.php'); exit; }
|
||||
|
||||
$gallery = db_gallery_get($pdo, $id);
|
||||
if (!$gallery) { header('Location: index.php'); exit; }
|
||||
|
||||
$errors = [];
|
||||
$name = $gallery['name'];
|
||||
$images = db_gallery_images($pdo, $id);
|
||||
|
||||
// Rename gallery
|
||||
if (isset($_POST['rename'])) {
|
||||
csrf_check();
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
if ($name === '') $errors[] = 'O nome é obrigatório.';
|
||||
elseif (db_gallery_update($pdo, $id, $name)) {
|
||||
session()->setFlashdata('success', 'Galeria renomeada.');
|
||||
header('Location: ' . base_url('views/admin/galerias/edit.php?id=' . $id));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Upload image
|
||||
if (isset($_FILES['image']) && $_FILES['image']['error'] !== UPLOAD_ERR_NO_FILE) {
|
||||
csrf_check();
|
||||
$result = db_gallery_image_upload($pdo, $id, $_FILES['image']);
|
||||
if ($result) session()->setFlashdata('success', 'Imagem carregada.');
|
||||
else session()->setFlashdata('error', 'Falha no upload. Verifique o formato.');
|
||||
header('Location: ' . base_url('views/admin/galerias/edit.php?id=' . $id));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Optimize existing images (resize/compress to the gallery cap)
|
||||
if (isset($_POST['optimize'])) {
|
||||
csrf_check();
|
||||
$stats = img_optimize_dir(__DIR__ . '/../../../uploads/gallery/' . $id . '/', IMG_MAX_GALLERY);
|
||||
session()->setFlashdata($stats['failed'] ? 'warning' : 'success', img_stats_message($stats));
|
||||
header('Location: ' . base_url('views/admin/galerias/edit.php?id=' . $id));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete image
|
||||
if (isset($_GET['del_img']) && is_numeric($_GET['del_img'])) {
|
||||
csrf_check();
|
||||
db_gallery_image_delete($pdo, (int) $_GET['del_img'], $id);
|
||||
session()->setFlashdata('success', 'Imagem removida.');
|
||||
header('Location: ' . base_url('views/admin/galerias/edit.php?id=' . $id));
|
||||
exit;
|
||||
}
|
||||
|
||||
$page_title = 'Gerir Galeria';
|
||||
include __DIR__ . '/../../../includes/header.php';
|
||||
?>
|
||||
<div class="container" style="max-width:900px;">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0"><?= htmlspecialchars($gallery['name']) ?></h1>
|
||||
<a class="btn btn-outline-secondary btn-sm" href="index.php"><i class="bi bi-arrow-left me-1"></i>Voltar</a>
|
||||
</div>
|
||||
<?php foreach ($errors as $e): ?><div class="alert alert-danger"><?= htmlspecialchars($e) ?></div><?php endforeach; ?>
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm"><div class="card-body">
|
||||
<h2 class="h6 mb-3">Renomear</h2>
|
||||
<form method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<div class="mb-3">
|
||||
<input class="form-control" name="name" value="<?= htmlspecialchars($name) ?>">
|
||||
</div>
|
||||
<button type="submit" name="rename" class="btn btn-primary btn-sm">Renomear</button>
|
||||
</form>
|
||||
</div></div>
|
||||
|
||||
<div class="card shadow-sm mt-3"><div class="card-body">
|
||||
<h2 class="h6 mb-3">Adicionar imagem</h2>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<?= csrf_field() ?>
|
||||
<div class="mb-3">
|
||||
<input type="file" class="form-control" name="image" accept=".jpg,.jpeg,.png,.gif,.webp">
|
||||
<div class="form-text">JPG, PNG, GIF ou WebP.</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-sm"><i class="bi bi-cloud-arrow-up me-1"></i>Carregar</button>
|
||||
</form>
|
||||
</div></div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="card shadow-sm"><div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h2 class="h6 mb-0">Imagens (<?= count($images) ?>)</h2>
|
||||
<?php if ($images): ?>
|
||||
<form method="POST" class="mb-0">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit" name="optimize" value="1" class="btn btn-sm btn-outline-success"
|
||||
title="Redimensiona e comprime as imagens desta galeria para o máximo de <?= IMG_MAX_GALLERY ?>px"
|
||||
onclick="return confirm('Otimizar todas as imagens desta galeria (máx. <?= IMG_MAX_GALLERY ?>px)? Os ficheiros originais serão substituídos.')">
|
||||
<i class="bi bi-arrows-angle-contract me-1"></i>Otimizar imagens
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (!$images): ?>
|
||||
<p class="text-muted">Nenhuma imagem nesta galeria.</p>
|
||||
<?php else: ?>
|
||||
<div class="row g-2">
|
||||
<?php foreach ($images as $img): ?>
|
||||
<div class="col-6 col-lg-4 position-relative">
|
||||
<img src="<?= base_url('uploads/gallery/' . $id . '/' . $img['i_file_name']) ?>"
|
||||
alt="" class="img-thumbnail w-100" style="height:140px;object-fit:cover;" loading="lazy">
|
||||
<a class="btn btn-sm btn-danger position-absolute top-0 end-0 m-1 rounded-circle"
|
||||
href="?id=<?= $id ?>&del_img=<?= $img['i_id'] ?>"
|
||||
onclick="return confirm('Remover esta imagem?')"
|
||||
style="width:28px;height:28px;display:flex;align-items:center;justify-content:center;font-size:12px">×</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../../../includes/footer.php'; ?>
|
||||
Reference in new issue
Block a user