<?php
// Include the config file
include 'config.php';
// Database connection parameters
$dbhost = $CONFIG['dbhost'];
$dbuser = $CONFIG['dbuser'];
$dbpassword = $CONFIG['dbpassword'];
$dbname = $CONFIG['dbname'];
// Create connection
$conn = new mysqli($dbhost, $dbuser, $dbpassword, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Query to fetch user information
$sql = "SELECT * FROM oc_users";
$result = $conn->query($sql);
// Check if any users found
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "ID: " . $row["uid"]. " - Username: " . $row["uid"]. " - Display Name: " . $row["displayname"]. "<br>";
}
} else {
echo "0 results";
}
// Close connection
$conn->close();
?>
import pymysql
# Database connection parameters
dbhost = "localhost"
dbuser = "nextcloud"
dbpassword = "kG0vW58f9kql1zJURcCGZ4XVQitMeIYWBoktQOOcbIZVt3EOvjb8fm6lyUo3JRjt"
dbname = "nextcloud"
# Connect to the database
conn = pymysql.connect(host=dbhost, user=dbuser, password=dbpassword, database=dbname)
try:
# Create a cursor object to interact with the database
with conn.cursor() as cursor:
# SQL query to fetch user information
sql = "SELECT * FROM oc_users"
# Execute the query
cursor.execute(sql)
# Fetch all the results
results = cursor.fetchall()
# Check if any users found
if results:
# Output user information
for row in results:
print("ID:", row[0], "- Username:", row[1], "- Display Name:", row[5])
else:
print("No users found")
finally:
# Close the connection
conn.close()