prepare("DELETE FROM shoutouts WHERE id = ?"); $stmt->bind_param("i", $id); if ($stmt->execute()) { $messages[] = "Shout-out #$id verwijderd."; } else { $messages[] = "Fout bij verwijderen: " . $db_conx->error; } $stmt->close(); } // Blokkeren / deblokkeren (voegt/uses 'blocked' boolean) if (isset($_POST['action']) && $_POST['action'] === 'toggle_block' && isset($_POST['id'])) { $id = intval($_POST['id']); // Zorg dat de kolom 'blocked' bestaat; als niet, maak hem aan $db_conx->query("ALTER TABLE shoutouts ADD COLUMN IF NOT EXISTS blocked TINYINT(1) NOT NULL DEFAULT 0"); // Haal huidig $res = $db_conx->query("SELECT blocked FROM shoutouts WHERE id = " . $id); if ($res && $row = $res->fetch_assoc()) { $new = $row['blocked'] ? 0 : 1; $stmt = $db_conx->prepare("UPDATE shoutouts SET blocked = ? WHERE id = ?"); $stmt->bind_param("ii", $new, $id); if ($stmt->execute()) { $messages[] = $new ? "Shout-out #$id geblokkeerd." : "Shout-out #$id vrijgegeven."; } else { $messages[] = "Fout bij updaten: " . $db_conx->error; } $stmt->close(); } } // Handmatig toevoegen if (isset($_POST['action']) && $_POST['action'] === 'add') { $name = trim($_POST['name'] ?? ''); $shout = trim($_POST['shoutout'] ?? ''); $photo = trim($_POST['photo'] ?? ''); if ($name === '' || $shout === '') { $messages[] = "Naam en shout-out zijn verplicht."; } else { $stmt = $db_conx->prepare("INSERT INTO shoutouts (name, shoutout, photo, created_at) VALUES (?, ?, ?, NOW())"); $stmt->bind_param("sss", $name, $shout, $photo); if ($stmt->execute()) { $messages[] = "Handmatige shout-out toegevoegd."; } else { $messages[] = "Fout bij toevoegen: " . $db_conx->error; } $stmt->close(); } } // Trigger AI generate (roept jouw data/generate_ai_shoutout.php aan) if (isset($_POST['action']) && $_POST['action'] === 'generate_ai') { // call local script via curl (server-side) $url = rtrim(dirname($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), '/') . '/../../data/generate_ai_shoutout.php'; // beter: lokale filesystem invocation met include zodat je niet afhankelijk bent van HTTP: $genPath = __DIR__ . '/../../data/generate_ai_shoutout.php'; if (is_file($genPath)) { // include in buffer om output te suppressen and avoid double headers ob_start(); include $genPath; $out = ob_get_clean(); $messages[] = "AI generator aangeroepen: " . strip_tags($out); } else { $messages[] = "AI generator niet gevonden op $genPath"; } } } // Pagination / zoek filter (eenvoudig) $page = max(1, intval($_GET['p'] ?? 1)); $perPage = 30; $offset = ($page - 1) * $perPage; $searchSql = ""; $params = []; if (!empty($_GET['q'])) { $q = '%' . $db_conx->real_escape_string($_GET['q']) . '%'; $searchSql = "WHERE (name LIKE ? OR shoutout LIKE ?)"; $params = [$q, $q]; } // Count totaal if ($searchSql === "") { $totalRes = $db_conx->query("SELECT COUNT(*) AS cnt FROM shoutouts"); $total = $totalRes->fetch_assoc()['cnt'] ?? 0; } else { $stmtc = $db_conx->prepare("SELECT COUNT(*) AS cnt FROM shoutouts $searchSql"); $stmtc->bind_param("ss", $params[0], $params[1]); $stmtc->execute(); $rc = $stmtc->get_result()->fetch_assoc(); $total = $rc['cnt'] ?? 0; $stmtc->close(); } $pages = max(1, ceil($total / $perPage)); // Haal data $rows = []; if ($searchSql === "") { $res = $db_conx->query("SELECT * FROM shoutouts ORDER BY id DESC LIMIT $perPage OFFSET $offset"); while ($r = $res->fetch_assoc()) $rows[] = $r; } else { $stmts = $db_conx->prepare("SELECT * FROM shoutouts $searchSql ORDER BY id DESC LIMIT ? OFFSET ?"); $stmts->bind_param("ssii", $params[0], $params[1], $perPage, $offset); // bind_param types adjusted below if needed // bind_param doesn't accept mixed types easily here — fallback to manual query $safeQ = $db_conx->real_escape_string($_GET['q']); $res = $db_conx->query("SELECT * FROM shoutouts WHERE (name LIKE '%$safeQ%' OR shoutout LIKE '%$safeQ%') ORDER BY id DESC LIMIT $perPage OFFSET $offset"); while ($r = $res->fetch_assoc()) $rows[] = $r; } ?> Admin – Shoutouts

Shoutouts beheer

Reset

Nieuwe shout-out toevoegen

AI acties

Genereer één AI-shoutout en sla direct op in DB.

Opschonen (houd max 200)

Opschonen via script

Shoutouts ()

# Datum Naam Shout-out Foto Geblokkeerd Acties
Geen shoutouts gevonden.
Geen