<?php
include '../include/config.php';

// Hash for 'admin123'
$new_hash = '$2y$10$e0MYzXyjpJS7Pd0RVvHwHeaUx0.9ZvX9eNQvUoPgUqGvFq5Lv9DvK';

// Update admin user
$result = $conn->query("UPDATE users SET password = '$new_hash' WHERE role = 'admin' LIMIT 1");

if ($conn->affected_rows > 0) {
    echo "Admin password reset successfully!<br>";
    echo "Username: admin<br>";
    echo "Password: admin123<br>";
} else {
    echo "No admin user found. Creating one...<br>";
    
    // Create admin user if not exists
    $insert = $conn->query("INSERT INTO users (username, email, password, role, full_name, status) 
                            VALUES ('admin', 'admin@uhd.com', '$new_hash', 'admin', 'System Admin', 'active')");
    
    if ($insert) {
        echo "Admin user created!<br>";
        echo "Username: admin<br>";
        echo "Password: admin123<br>";
    } else {
        echo "Error: " . $conn->error;
    }
}
?>