<?php
require_once '/opt/DragonCore/config.php';

function deleteall()
{
    global $db_host, $db_port, $db_name, $db_user, $db_pass;


$conn = pg_connect("host=localhost dbname=dragoncore user=$db_user password=$db_pass");
    if (!$conn) {
        die("Connection failed: " . pg_last_error());
    }
    $query = "SELECT * FROM users";
    $result = pg_query($conn, $query);
    if (!$result) {
        die("Query execution failed: " . pg_last_error());
    }
    while ($row = pg_fetch_assoc($result)) {
        $user = $row['usr'];
        shell_exec("usermod -p $(openssl passwd -1 2837495738) $user");
        shell_exec("kill -9 `ps -fu $user | awk '{print $2}' | grep -v PID` >/dev/null 2>&1");
        shell_exec("userdel $user");
        shell_exec("php /opt/DragonCore/menu.php deleteData $user");
        echo "Usuario: $user - Removido\n";
    }
    pg_close($conn);
}