diff --git a/dashboard.php b/dashboard.php
new file mode 100644
index 0000000..1c5be92
--- /dev/null
+++ b/dashboard.php
@@ -0,0 +1,314 @@
+ PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+];
+
+try {
+ $pdo = new PDO($dsn, $user, $pass, $options);
+} catch (PDOException $e) {
+ header('Content-Type: application/json');
+ echo json_encode(['error' => 'Database connection failed: ' . $e->getMessage()]);
+ exit;
+}
+
+// Bearer Token für Mastodon-API (falls benötigt – hier nicht direkt in diesem File)
+$bearerToken = 'your_bearer_token_here';
+
+// Falls eine AJAX-Anfrage vorliegt, wird über den Parameter "action" unterschieden.
+if (isset($_POST['action'])) {
+ $action = $_POST['action'];
+ header('Content-Type: application/json');
+
+ if ($action === 'save_hashtags') {
+ // Erwartet ein Array "hashtags" (JSON-dekodiert via AJAX)
+ $hashtags = isset($_POST['hashtags']) ? $_POST['hashtags'] : [];
+ $response = ['saved' => 0, 'updated' => 0];
+
+ foreach ($hashtags as $row) {
+ // Falls eine ID vorhanden ist, update ansonsten insert
+ if (isset($row['hashtag_id']) && !empty($row['hashtag_id'])) {
+ // Update vorhandener Eintrag
+ $stmt = $pdo->prepare("UPDATE hashtags SET hashtag = :hashtag, active = :active WHERE hashtag_id = :hashtag_id");
+ $stmt->execute([
+ 'hashtag' => $row['hashtag'],
+ 'active' => !empty($row['active']) ? 1 : 0,
+ 'hashtag_id' => $row['hashtag_id']
+ ]);
+ $response['updated']++;
+ } else {
+ // Insert neuer Eintrag
+ $stmt = $pdo->prepare("INSERT INTO hashtags (hashtag, active) VALUES (:hashtag, :active)");
+ $stmt->execute([
+ 'hashtag' => $row['hashtag'],
+ 'active' => !empty($row['active']) ? 1 : 0
+ ]);
+ $response['saved']++;
+ }
+ }
+ echo json_encode($response);
+ exit;
+ } elseif ($action === 'save_accounts') {
+ // Erwartet ein Array "accounts" (JSON)
+ $accounts = isset($_POST['accounts']) ? $_POST['accounts'] : [];
+ $response = ['updated' => 0];
+
+ foreach ($accounts as $row) {
+ // Aktualisiere den active-Status in der Tabelle "users"
+ // Annahme: Tabelle "users" hat die Spalten: acc_id, username, active
+ $stmt = $pdo->prepare("UPDATE users SET active = :active WHERE acc_id = :acc_id");
+ $stmt->execute([
+ 'active' => !empty($row['active']) ? 1 : 0,
+ 'acc_id' => $row['acc_id']
+ ]);
+ $response['updated']++;
+ }
+ echo json_encode($response);
+ exit;
+ } elseif ($action === 'sync_accounts') {
+ // Synchronisation: Aus der findings-Tabelle werden alle getrackten Accounts (acc_id, username) ermittelt
+ // Für jeden Account, der noch nicht in der "users"-Tabelle existiert, erfolgt ein Insert mit active=0
+ $stmt = $pdo->query("SELECT DISTINCT acc_id, username FROM findings");
+ $tracked = $stmt->fetchAll();
+
+ foreach ($tracked as $acc) {
+ // Prüfen, ob der Account bereits in der users-Tabelle existiert
+ $checkStmt = $pdo->prepare("SELECT COUNT(*) as cnt FROM users WHERE acc_id = :acc_id");
+ $checkStmt->execute(['acc_id' => $acc['acc_id']]);
+ $exists = $checkStmt->fetch();
+ if ($exists['cnt'] == 0) {
+ // Neuer Account – unaktiv in die Tabelle schreiben
+ $insertStmt = $pdo->prepare("INSERT INTO users (acc_id, username, active) VALUES (:acc_id, :username, 0)");
+ $insertStmt->execute([
+ 'acc_id' => $acc['acc_id'],
+ 'username' => $acc['username']
+ ]);
+ }
+ }
+ // Nun alle Accounts aus der users-Tabelle abrufen
+ $stmt = $pdo->query("SELECT acc_id, username, active FROM users ORDER BY username ASC");
+ $accountsList = $stmt->fetchAll();
+ echo json_encode($accountsList);
+ exit;
+ }
+ // Weitere Aktionen können hier ergänzt werden
+ exit;
+}
+
+// Wenn kein "action" gesetzt ist, wird der HTML-Teil (Dashboard) ausgegeben.
+// Der Konfigbereich ist über den Parameter "setup" erreichbar.
+?>
+
+
+
+
+ Dashboard & Konfiguration
+
+
+
+
+
+ Dashboard - Konfigurationsbereich
+
+
+
Zeitraum definieren (von - bis)
+
+
+
+
+
+
+
+
+
Hashtags
+
+
+
+
+
+
+
+
Getrackte Accounts
+
+
+
+
+
+
+
+
+
+ | Acc_ID |
+ Username |
+ Aktiv |
+
+
+
+
+
+
+
+
+
+
+
+