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:
38
get_talk_rooms.sh
Normal file
38
get_talk_rooms.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Skript zum Auflisten aller Nextcloud Talk Räume aus der Datenbank
|
||||
# Benötigt PHP auf dem Nextcloud-Server
|
||||
|
||||
# Farben
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Nextcloud-Verzeichnis finden
|
||||
if [ -f "./config/config.php" ]; then
|
||||
NEXTCLOUD_DIR="."
|
||||
else
|
||||
for path in /mnt/data/updater-ocubwyrxncdg/backups/nextcloud-34.0.3.2-1790150204 /var/www/nextcloud /var/www/html/nextcloud /usr/share/nextcloud /srv/nextcloud /opt/nextcloud; do
|
||||
[ -f "$path/config/config.php" ] && NEXTCLOUD_DIR="$path" && break
|
||||
done
|
||||
[ -z "$NEXTCLOUD_DIR" ] && echo -e "${RED}Fehler: Nextcloud-Verzeichnis nicht gefunden!${NC}" && exit 1
|
||||
fi
|
||||
|
||||
# PHP-Pfad finden
|
||||
PHP_PATH="$(which php 2>/dev/null)"
|
||||
for php_bin in /usr/bin/php /usr/bin/php8.* /usr/bin/php7.* /usr/local/bin/php; do
|
||||
[ -x "$php_bin" ] && PHP_PATH="$php_bin" && break
|
||||
done
|
||||
[ -z "$PHP_PATH" ] && echo -e "${RED}Fehler: PHP nicht gefunden!${NC}" && exit 1
|
||||
|
||||
# PHP-Skript ausführen
|
||||
echo -e "${BLUE}=================================================================${NC}"
|
||||
echo -e "${BLUE} Nextcloud Talk Räume aus der Datenbank${NC}"
|
||||
echo -e "${BLUE}=================================================================${NC}\n"
|
||||
|
||||
$PHP_PATH "${NEXTCLOUD_DIR}/list_talk_rooms.php"
|
||||
|
||||
echo ""
|
||||
read -p "Drücken Sie Enter zum Fortfahren..."
|
||||
45
list_rooms_mysql.sh
Normal file
45
list_rooms_mysql.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Direktes MySQL-Skript zum Auflisten aller Talk-Räume
|
||||
# Benötigt mysql-Client
|
||||
|
||||
DB_HOST="localhost"
|
||||
DB_USER="d037e856"
|
||||
DB_PASS="aUVp7cvBdKyKac5HGmsw"
|
||||
DB_NAME="d037e856"
|
||||
DB_PREFIX="kwcL2_"
|
||||
|
||||
# MySQL-Befehl aufbauen
|
||||
MYSQL_CMD="mysql -h $DB_HOST -u $DB_USER -p'$DB_PASS' $DB_NAME"
|
||||
|
||||
echo "================================================================="
|
||||
echo " Nextcloud Talk Räume aus der Datenbank"
|
||||
echo "================================================================="
|
||||
echo ""
|
||||
|
||||
# Zuerst prüfen, welche Talk-Tabellen existieren
|
||||
echo "Suche nach Talk-Tabellen..."
|
||||
$MYSQL_CMD -e "SHOW TABLES LIKE '%${DB_PREFIX}talk%rooms%' OR TABLES LIKE '%${DB_PREFIX}spreed%rooms%'" 2>/dev/null
|
||||
|
||||
echo ""
|
||||
|
||||
# Standard-Tabelle abfragen
|
||||
TABLE_NAME="${DB_PREFIX}talk_rooms"
|
||||
echo "Abfrage der Tabelle: $TABLE_NAME"
|
||||
$MYSQL_CMD -e "SELECT token AS Token, name AS Name, type AS Typ, id AS ID FROM \`$TABLE_NAME\` ORDER BY name ASC;" 2>/dev/null
|
||||
|
||||
# Wenn keine Ergebnisse, alternative Tabellen versuchen
|
||||
if [ $? -ne 0 ]; then
|
||||
for ALT_TABLE in "${DB_PREFIX}spreed_rooms" "${DB_PREFIX}oc_talk_rooms" "${DB_PREFIX}oc_spreed_rooms"; do
|
||||
echo ""
|
||||
echo "Versuche alternative Tabelle: $ALT_TABLE"
|
||||
$MYSQL_CMD -e "SELECT token AS Token, name AS Name, type AS Typ, id AS ID FROM \`$ALT_TABLE\` ORDER BY name ASC;" 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
TABLE_NAME="$ALT_TABLE"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Fertig!"
|
||||
123
list_talk_rooms.php
Normal file
123
list_talk_rooms.php
Normal 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");
|
||||
}
|
||||
Reference in New Issue
Block a user