From 555000c1cd22276c1288871a14afa927d73080a8 Mon Sep 17 00:00:00 2001 From: Metacube Date: Sun, 5 Apr 2026 09:01:21 +0200 Subject: [PATCH] Delete link.php --- link.php | 679 ------------------------------------------------------- 1 file changed, 679 deletions(-) delete mode 100644 link.php diff --git a/link.php b/link.php deleted file mode 100644 index e65f7b6..0000000 --- a/link.php +++ /dev/null @@ -1,679 +0,0 @@ - Score) - * - Optionales Vorschaubild (YouTube-Icon bei youtube.com) - * - Optionales Hintergrundbild (konfigurierbar) - ***************************************************************/ - -session_start(); - -// ---------------------- Konfiguration ------------------------- -// Beispiel-Nutzer (Benutzername: admin / Passwort: gradio) -$USER_CREDENTIALS = [ - 'admin' => 'gradio' -]; - -// Dateiname, in dem unsere Links gespeichert werden -$LINKS_FILE = __DIR__ . '/links.json'; - -// Optionales Hintergrundbild (leer lassen, falls kein Hintergrundbild) -$BACKGROUND_IMAGE = ""; -// Beispiel: $BACKGROUND_IMAGE = "https://via.placeholder.com/1200x800/404040/FFFFFF?text=Background"; - -// ---------------------- Hilfsfunktionen ----------------------- -/** - * Lädt die Linkliste aus dem JSON-File - * - * @return array - */ -function loadLinks($file) -{ - if (!file_exists($file)) { - return []; - } - $jsonData = file_get_contents($file); - return json_decode($jsonData, true) ?? []; -} - -/** - * Schreibt die Linkliste in das JSON-File - * - * @param array $linksArray - * @param string $file - */ -function saveLinks($linksArray, $file) -{ - file_put_contents($file, json_encode($linksArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); -} - -/** - * Prüft, ob ein Nutzer eingeloggt ist. - * - * @return bool - */ -function isLoggedIn() -{ - return isset($_SESSION['username']); -} - -// ---------------------- Login/Logout-Prozess ------------------ -if (isset($_POST['action']) && $_POST['action'] === 'login') { - // Login-Formular wurde abgeschickt - $username = trim($_POST['username'] ?? ''); - $password = trim($_POST['password'] ?? ''); - - global $USER_CREDENTIALS; - if (array_key_exists($username, $USER_CREDENTIALS) && - $USER_CREDENTIALS[$username] === $password - ) { - $_SESSION['username'] = $username; - } else { - $loginError = 'Falscher Benutzername oder Passwort!'; - } -} elseif (isset($_POST['action']) && $_POST['action'] === 'logout') { - // Logout - session_destroy(); - header("Location: {$_SERVER['PHP_SELF']}"); - exit; -} - -// ---------------------- Link-Management ----------------------- -$links = loadLinks($LINKS_FILE); - -// Falls wir per GET "go" einen Link aufrufen, Klickzähler erhöhen und weiterleiten -if (isset($_GET['go'])) { - $goIndex = intval($_GET['go']); - if (isset($links[$goIndex])) { - // Klickzähler um 1 erhöhen - $links[$goIndex]['clicks'] = ($links[$goIndex]['clicks'] ?? 0) + 1; - saveLinks($links, $LINKS_FILE); - - // Weiterleitung zum tatsächlichen Ziel - header("Location: " . $links[$goIndex]['url']); - exit; - } -} - -// Link hinzufügen/bearbeiten/löschen/favorisieren/voten nur, wenn eingeloggt -if (isLoggedIn()) { - - // Link hinzufügen - if (isset($_POST['action']) && $_POST['action'] === 'add_link') { - $newTitle = trim($_POST['title'] ?? ''); - $newUrl = trim($_POST['url'] ?? ''); - $newImgUrl = trim($_POST['image'] ?? ''); - - if ($newTitle !== '' && $newUrl !== '') { - $links[] = [ - 'title' => $newTitle, - 'url' => $newUrl, - 'image' => $newImgUrl, - 'clicks' => 0, - 'favorite' => false, - 'score' => 0 // neu fürs Voting - ]; - saveLinks($links, $LINKS_FILE); - header("Location: {$_SERVER['PHP_SELF']}"); - exit; - } - } - - // Link bearbeiten - if (isset($_POST['action']) && $_POST['action'] === 'edit_link') { - $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; - // Sicherstellen, dass Klickzähler, Favoriten, Score ex. sind - $links[$editIndex]['clicks'] = $links[$editIndex]['clicks'] ?? 0; - $links[$editIndex]['favorite'] = $links[$editIndex]['favorite'] ?? false; - $links[$editIndex]['score'] = $links[$editIndex]['score'] ?? 0; - - saveLinks($links, $LINKS_FILE); - header("Location: {$_SERVER['PHP_SELF']}"); - exit; - } - } - - // Link löschen - if (isset($_POST['action']) && $_POST['action'] === 'delete_link') { - $deleteIndex = intval($_POST['index'] ?? -1); - - if ($deleteIndex >= 0 && isset($links[$deleteIndex])) { - array_splice($links, $deleteIndex, 1); - saveLinks($links, $LINKS_FILE); - header("Location: {$_SERVER['PHP_SELF']}"); - exit; - } - } - - // Favorit toggeln - if (isset($_POST['action']) && $_POST['action'] === 'toggle_fav') { - $favIndex = intval($_POST['index'] ?? -1); - if ($favIndex >= 0 && isset($links[$favIndex])) { - $isFav = $links[$favIndex]['favorite'] ?? false; - $links[$favIndex]['favorite'] = !$isFav; - saveLinks($links, $LINKS_FILE); - header("Location: {$_SERVER['PHP_SELF']}"); - exit; - } - } - - // Voting Up/Down - if (isset($_POST['action']) && in_array($_POST['action'], ['vote_up', 'vote_down'])) { - $voteIndex = intval($_POST['index'] ?? -1); - if ($voteIndex >= 0 && isset($links[$voteIndex])) { - $links[$voteIndex]['score'] = $links[$voteIndex]['score'] ?? 0; - if ($_POST['action'] === 'vote_up') { - $links[$voteIndex]['score']++; - } else { - $links[$voteIndex]['score']--; - } - saveLinks($links, $LINKS_FILE); - header("Location: {$_SERVER['PHP_SELF']}"); - exit; - } - } -} - -// ---------------------- Suchfunktion (für alle User) ---------- -$searchQuery = trim($_GET['search'] ?? ''); - -// Links filtern (Titel oder URL enthalten den Suchbegriff) -$filteredLinks = array_filter($links, function($link) use ($searchQuery) { - if ($searchQuery === '') return true; // Nichts gesucht -> Alle Links - return (stripos($link['title'], $searchQuery) !== false || - stripos($link['url'], $searchQuery) !== false); -}); -?> - - - - - - Amateurfunk-Linkliste - - - -
-
-
📻
-

Amateurfunk-Linkliste

-
- - - - - - - - - -
-
- - -
-
- - - - - - -
-

Neuen Link hinzufügen

-
- - - - - - - - - - - - -
-
- - - -
- -