Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/fix_superuser.php

<?php
/**
 * Fix Superuser Account
 * Updates the superuser password hash and verifies account
 */

require_once 'config/config.php';

try {
    $db = Database::getInstance()->getConnection();
    
    echo "<h2>Fixing Superuser Account</h2>";
    
    // Generate proper password hash for 'password123'
    $correctHash = password_hash('password123', PASSWORD_BCRYPT);
    
    echo "<p>Generated new password hash: <code>" . htmlspecialchars($correctHash) . "</code></p>";
    
    // Update the superuser account
    $stmt = $db->prepare("
        UPDATE users 
        SET password_hash = :hash,
            is_superuser = 1,
            access_level = 'superuser',
            is_active = 1
        WHERE username = 'nabibo'
    ");
    
    $stmt->execute(['hash' => $correctHash]);
    
    echo "<p style='color: green;'>✅ Superuser account updated successfully!</p>";
    
    // Verify the account
    $stmt = $db->prepare("SELECT * FROM users WHERE username = 'nabibo'");
    $stmt->execute();
    $user = $stmt->fetch();
    
    if ($user) {
        echo "<h3>Superuser Account Details:</h3>";
        echo "<ul>";
        echo "<li><strong>Username:</strong> " . htmlspecialchars($user['username']) . "</li>";
        echo "<li><strong>Email:</strong> " . htmlspecialchars($user['email']) . "</li>";
        echo "<li><strong>Full Name:</strong> " . htmlspecialchars($user['full_name']) . "</li>";
        echo "<li><strong>Is Superuser:</strong> " . ($user['is_superuser'] ? 'YES' : 'NO') . "</li>";
        echo "<li><strong>Access Level:</strong> " . htmlspecialchars($user['access_level']) . "</li>";
        echo "<li><strong>Is Active:</strong> " . ($user['is_active'] ? 'YES' : 'NO') . "</li>";
        echo "</ul>";
        
        // Test password verification
        if (password_verify('password123', $user['password_hash'])) {
            echo "<p style='color: green;'>✅ Password verification successful!</p>";
        } else {
            echo "<p style='color: red;'>❌ Password verification failed!</p>";
        }
    } else {
        echo "<p style='color: red;'>❌ Superuser account not found!</p>";
    }
    
} catch (Exception $e) {
    echo "<p style='color: red;'>❌ Error: " . htmlspecialchars($e->getMessage()) . "</p>";
}

echo "<hr>";
echo "<p><strong>Login Credentials:</strong></p>";
echo "<ul>";
echo "<li>Username: <code>nabibo</code></li>";
echo "<li>Password: <code>password123</code></li>";
echo "</ul>";
echo "<p><a href='login.php'>← Go to Login</a> | <a href='dashboard.php'>Dashboard</a></p>";
?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists