<?php
// Admin Password Update Script
// Run this file once: http://dashboard-update.test/update_admin.php

include "core/dbInfo.php";
include "core/dbFunctions.php";

$new_username = "ADMIN";
$new_password = "12345";

// Calculate hashed password using same function as login
$hashed_password = abs(crc32(md5($new_password)));

echo "New Username: " . $new_username . "<br>";
echo "New Password: " . $new_password . "<br>";
echo "Hashed Password: " . $hashed_password . "<br><br>";

// Update query
$con = connect_database();
$sql = "UPDATE users SET user_name = '$new_username', email = '$new_username', password = '$hashed_password', user_type = 'Admin', is_active = 1 WHERE user_id = 1";

if(mysqli_query($con, $sql)) {
    echo "<h2 style='color:green;'>Admin credentials updated successfully!</h2>";
    echo "<p>Login URL: <a href='swabhimanmfiADMIN/login.php'>Click here to login</a></p>";
    echo "<p>Username: <b>ADMIN</b></p>";
    echo "<p>Password: <b>12345</b></p>";
} else {
    echo "<h2 style='color:red;'>Error: " . mysqli_error($con) . "</h2>";
}

mysqli_close($con);

echo "<br><br><b style='color:red;'>IMPORTANT: Delete this file after use for security!</b>";
?>
