Add scripts to list Talk rooms from database

- list_talk_rooms.php: PHP script using Nextcloud config
- get_talk_rooms.sh: Bash wrapper for PHP script
- list_rooms_mysql.sh: Direct MySQL script

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
wralto-user-1
2026-10-31 14:04:21 +01:00
parent 6b01d1bc7b
commit 3e3fcd6624
3 changed files with 206 additions and 0 deletions

123
list_talk_rooms.php Normal file
View File

@ -0,0 +1,123 @@
<?php
/**
* Nextcloud Talk Räume aus der Datenbank auflisten
* Nutzt die Nextcloud-Datenbankverbindung
*/
// Pfad zur Nextcloud config.php
$nextcloudConfigPath = '/mnt/data/updater-ocubwyrxncdg/backups/nextcloud-34.0.3.2-1790150204/config/config.php';
if (!file_exists($nextcloudConfigPath)) {
// Alternative Pfade
$possiblePaths = [
'./config/config.php',
'/var/www/nextcloud/config/config.php',
'/var/www/html/nextcloud/config/config.php',
'/usr/share/nextcloud/config/config.php',
'/srv/nextcloud/config/config.php',
'/opt/nextcloud/config/config.php'
];
foreach ($possiblePaths as $path) {
if (file_exists($path)) {
$nextcloudConfigPath = $path;
break;
}
}
}
if (!file_exists($nextcloudConfigPath)) {
die("Fehler: config.php nicht gefunden!\n");
}
// Nextcloud-Konfiguration laden
$config = include $nextcloudConfigPath;
// Datenbankverbindung herstellen
$dbHost = $config['dbhost'] ?? 'localhost';
$dbUser = $config['dbuser'] ?? '';
$dbPass = $config['dbpassword'] ?? '';
$dbName = $config['dbname'] ?? '';
$dbPrefix = $config['dbtableprefix'] ?? '';
// MySQL-Verbindung
try {
$pdo = new PDO(
"mysql:host=$dbHost;dbname=$dbName;charset=utf8mb4",
$dbUser,
$dbPass,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]
);
} catch (Exception $e) {
die("Fehler: Datenbankverbindung fehlgeschlagen: " . $e->getMessage() . "\n");
}
// Talk-Räume abfragen
$tableName = $dbPrefix . 'talk_rooms';
try {
$stmt = $pdo->query("SELECT * FROM `$tableName` ORDER BY name ASC");
$rooms = $stmt->fetchAll();
if (empty($rooms)) {
// Alternative Tabellennamen versuchen
$alternativeTables = [
$dbPrefix . 'spreed_rooms',
$dbPrefix . 'oc_talk_rooms',
$dbPrefix . 'oc_spreed_rooms'
];
foreach ($alternativeTables as $altTable) {
try {
$stmt = $pdo->query("SELECT * FROM `$altTable` ORDER BY name ASC");
$rooms = $stmt->fetchAll();
if (!empty($rooms)) {
$tableName = $altTable;
break;
}
} catch (Exception $e) {
continue;
}
}
}
if (empty($rooms)) {
// Alle Tabellen mit 'room' oder 'talk' oder 'spreed' suchen
$stmt = $pdo->query("SHOW TABLES LIKE '%{$dbPrefix}room%' OR TABLES LIKE '%{$dbPrefix}talk%' OR TABLES LIKE '%{$dbPrefix}spreed%");
$tables = $stmt->fetchAll();
echo "Keine Talk-Räume gefunden. Verwendete Tabelle: $tableName\n\n";
echo "Verfügbare Tabellen mit 'room', 'talk' oder 'spreed':\n";
foreach ($tables as $table) {
foreach ($table as $t) {
echo " - $t\n";
}
}
exit(1);
}
// Ergebnis ausgeben
echo "=================================================================\n";
echo " Nextcloud Talk Räume (Datenbank: $dbName)\n";
echo "=================================================================\n\n";
printf("%-36s | %-25s | %-12s | %s\n", "Token", "Name", "Typ", "ID");
echo str_repeat("-", 90) . "\n";
foreach ($rooms as $room) {
$token = $room['token'] ?? $room['room_token'] ?? 'N/A';
$name = $room['name'] ?? $room['room_name'] ?? 'N/A';
$type = $room['type'] ?? $room['room_type'] ?? 'N/A';
$id = $room['id'] ?? $room['room_id'] ?? 'N/A';
printf("%-36s | %-25s | %-12s | %s\n", $token, $name, $type, $id);
}
echo "\nGesamt: " . count($rooms) . " Räume gefunden\n";
} catch (Exception $e) {
die("Fehler beim Abfragen der Talk-Räume: " . $e->getMessage() . "\n");
}