Gallery
This commit is contained in:
+12
-8
@@ -76,6 +76,14 @@ try {
|
||||
if ($method === 'DELETE') { return messwerte_delete($pdo, $uid, $mid); }
|
||||
}
|
||||
|
||||
// --- Einzelnes Bild löschen (TOP-LEVEL!) -----------------------------------
|
||||
// /images/{imgId} → DELETE
|
||||
if (preg_match('#^/images/(\d+)$#', $path, $m)) {
|
||||
$uid = require_user($pdo);
|
||||
$imgId = (int)$m[1];
|
||||
if ($method === 'DELETE') { return igel_images_delete($pdo, $uid, $imgId); }
|
||||
}
|
||||
|
||||
// --- Igel + Unterressourcen -----------------------------------------------
|
||||
if (str_starts_with($path, '/igel')) {
|
||||
$uid = require_user($pdo);
|
||||
@@ -99,12 +107,6 @@ try {
|
||||
if ($method === 'POST') { return igel_images_upload($pdo, $uid, $igId); }
|
||||
}
|
||||
|
||||
// /images/{imgId}
|
||||
if (preg_match('#^/images/(\d+)$#', $path, $m)) {
|
||||
$imgId = (int)$m[1];
|
||||
if ($method === 'DELETE') { return igel_images_delete($pdo, $uid, $imgId); }
|
||||
}
|
||||
|
||||
// /igel/{id}/messwerte (Liste + Neu)
|
||||
if (preg_match('#^/igel/(\d+)/messwerte$#', $path, $m)) {
|
||||
$igId = (int)$m[1];
|
||||
@@ -361,7 +363,7 @@ function igel_images_upload(PDO $pdo, int $uid, int $igId): void {
|
||||
|
||||
$id = (int)$pdo->lastInsertId();
|
||||
|
||||
// created_at aus DB holen (für Response, damit Frontend sofort beides hat)
|
||||
// created_at/taken_at für Response aus DB holen
|
||||
$row = $pdo->prepare('SELECT created_at, taken_at FROM igel_images WHERE id=?');
|
||||
$row->execute([$id]);
|
||||
$times = $row->fetch(PDO::FETCH_ASSOC) ?: ['created_at'=>null,'taken_at'=>null];
|
||||
@@ -665,9 +667,11 @@ CREATE TABLE igel_images (
|
||||
original_name VARCHAR(255) NULL,
|
||||
mime VARCHAR(100) NULL,
|
||||
size_bytes BIGINT UNSIGNED NULL,
|
||||
taken_at DATETIME NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (igel_id) REFERENCES igel(id) ON DELETE CASCADE,
|
||||
INDEX (igel_id)
|
||||
INDEX (igel_id),
|
||||
INDEX (taken_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE messwerte (
|
||||
|
||||
Reference in New Issue
Block a user