From 131fd5c6bd9ffe61e557a7f24926d809d7cb33ef Mon Sep 17 00:00:00 2001 From: Metacube Date: Sun, 22 Dec 2024 09:06:03 +0100 Subject: [PATCH] Update link.php neu versaion --- link.php | 226 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 149 insertions(+), 77 deletions(-) diff --git a/link.php b/link.php index a648a56..679054b 100644 --- a/link.php +++ b/link.php @@ -1,13 +1,14 @@ 'gradio' ]; @@ -15,8 +16,6 @@ $USER_CREDENTIALS = [ // Dateiname, in dem unsere Links gespeichert werden $LINKS_FILE = __DIR__ . '/links.json'; -// ---------------------- Funktionen ---------------------------- - /** * Lädt die Linkliste aus dem JSON-File * @@ -52,13 +51,12 @@ function isLoggedIn() return isset($_SESSION['username']); } -// ---------------------- Login/Logout -------------------------- +// ---------------------- Login/Logout-Prozess ------------------ if (isset($_POST['action']) && $_POST['action'] === 'login') { // Login-Formular wurde abgeschickt $username = trim($_POST['username'] ?? ''); $password = trim($_POST['password'] ?? ''); - // Check Benutzername und Passwort global $USER_CREDENTIALS; if (array_key_exists($username, $USER_CREDENTIALS) && $USER_CREDENTIALS[$username] === $password @@ -82,13 +80,15 @@ if (isLoggedIn()) { // Link hinzufügen if (isset($_POST['action']) && $_POST['action'] === 'add_link') { - $newTitle = trim($_POST['title'] ?? ''); - $newUrl = trim($_POST['url'] ?? ''); - + $newTitle = trim($_POST['title'] ?? ''); + $newUrl = trim($_POST['url'] ?? ''); + $newImgUrl = trim($_POST['image'] ?? ''); // Bild-URL (optional) + if ($newTitle !== '' && $newUrl !== '') { $links[] = [ 'title' => $newTitle, - 'url' => $newUrl + 'url' => $newUrl, + 'image' => $newImgUrl ]; saveLinks($links, $LINKS_FILE); header("Location: {$_SERVER['PHP_SELF']}"); @@ -101,10 +101,12 @@ if (isLoggedIn()) { $editIndex = intval($_POST['index'] ?? -1); $editTitle = trim($_POST['title'] ?? ''); $editUrl = trim($_POST['url'] ?? ''); - + $editImg = trim($_POST['image'] ?? ''); + if ($editIndex >= 0 && isset($links[$editIndex])) { $links[$editIndex]['title'] = $editTitle; $links[$editIndex]['url'] = $editUrl; + $links[$editIndex]['image'] = $editImg; saveLinks($links, $LINKS_FILE); header("Location: {$_SERVER['PHP_SELF']}"); exit; @@ -123,8 +125,6 @@ if (isLoggedIn()) { } } } - -// ---------------------- HTML-Ausgabe -------------------------- ?> @@ -133,24 +133,35 @@ if (isLoggedIn()) { Amateurfunk-Linkliste @@ -306,7 +344,7 @@ if (isLoggedIn()) {

Amateurfunk-Linkliste

- +
@@ -337,26 +375,51 @@ if (isLoggedIn()) {