Sindbad~EG File Manager
<?php
require_once '../config/config.php';
echo "<h2>Fix Superuser Account</h2>";
// Generate correct password hash for 'password123'
$correct_password = 'password123';
$correct_hash = password_hash($correct_password, PASSWORD_DEFAULT);
echo "<p><strong>Correct password:</strong> $correct_password</p>";
echo "<p><strong>New hash:</strong> $correct_hash</p>";
$db = new Database();
$conn = $db->getConnection();
try {
// Check if superuser exists
$check_query = "SELECT * FROM users WHERE username = 'nabibo' OR email = 'nabibo2@yahoo.co.uk'";
$stmt = $conn->prepare($check_query);
$stmt->execute();
$existing_user = $stmt->fetch();
if ($existing_user) {
echo "<h3>Existing Superuser Found:</h3>";
echo "<ul>";
echo "<li>ID: {$existing_user['id']}</li>";
echo "<li>Username: {$existing_user['username']}</li>";
echo "<li>Email: {$existing_user['email']}</li>";
echo "<li>Full Name: {$existing_user['full_name']}</li>";
echo "<li>Role: {$existing_user['role']}</li>";
echo "<li>Active: " . ($existing_user['is_active'] ? 'Yes' : 'No') . "</li>";
echo "</ul>";
// Update the password
$update_query = "UPDATE users SET password = ?, is_active = 1 WHERE id = ?";
$stmt = $conn->prepare($update_query);
$stmt->execute([$correct_hash, $existing_user['id']]);
echo "<p style='color: green;'><strong>✓ Password updated successfully!</strong></p>";
} else {
echo "<h3>No Superuser Found - Creating New Account:</h3>";
// Create new superuser
$insert_query = "INSERT INTO users (username, email, password, full_name, role, is_active)
VALUES (?, ?, ?, ?, 'superuser', 1)";
$stmt = $conn->prepare($insert_query);
$stmt->execute([
'nabibo',
'nabibo2@yahoo.co.uk',
$correct_hash,
'Super Administrator'
]);
echo "<p style='color: green;'><strong>✓ Superuser account created successfully!</strong></p>";
}
// Test the login
echo "<h3>Testing Login:</h3>";
$test_query = "SELECT * FROM users WHERE username = 'nabibo'";
$stmt = $conn->prepare($test_query);
$stmt->execute();
$user = $stmt->fetch();
if ($user && password_verify($correct_password, $user['password'])) {
echo "<p style='color: green;'><strong>✓ Login test successful!</strong></p>";
echo "<p>You can now login with:</p>";
echo "<ul>";
echo "<li><strong>Username:</strong> nabibo</li>";
echo "<li><strong>Email:</strong> nabibo2@yahoo.co.uk</li>";
echo "<li><strong>Password:</strong> password123</li>";
echo "</ul>";
} else {
echo "<p style='color: red;'><strong>✗ Login test failed!</strong></p>";
}
// Show all users for debugging
echo "<h3>All Users in Database:</h3>";
$all_users_query = "SELECT id, username, email, full_name, role, is_active FROM users";
$stmt = $conn->prepare($all_users_query);
$stmt->execute();
$all_users = $stmt->fetchAll();
if ($all_users) {
echo "<table border='1' cellpadding='5' cellspacing='0'>";
echo "<tr><th>ID</th><th>Username</th><th>Email</th><th>Full Name</th><th>Role</th><th>Active</th></tr>";
foreach ($all_users as $user) {
$active = $user['is_active'] ? 'Yes' : 'No';
echo "<tr>";
echo "<td>{$user['id']}</td>";
echo "<td>{$user['username']}</td>";
echo "<td>{$user['email']}</td>";
echo "<td>{$user['full_name']}</td>";
echo "<td>{$user['role']}</td>";
echo "<td>$active</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<p>No users found in database.</p>";
}
} catch (Exception $e) {
echo "<p style='color: red;'><strong>Error:</strong> " . $e->getMessage() . "</p>";
}
echo "<hr>";
echo "<p><a href='login.php'>→ Try Login Now</a></p>";
echo "<p><a href='dashboard.php'>→ Go to Dashboard</a></p>";
?>
<style>
table {
border-collapse: collapse;
width: 100%;
margin: 10px 0;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
font-weight: bold;
}
</style>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists