Subversion Repositories ALCASAR

Rev

Rev 2226 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

<?php
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
        include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
else{
        echo "<b>Could not include SQL library</b><br>\n";
        exit();
}
$link = da_sql_pconnect($config);
if ($link){
        $res = da_sql_query($link,$config,
                "DELETE FROM $config[sql_reply_table] WHERE username = '$login';");
        if ($res){
                $res = da_sql_query($link,$config,
                        "DELETE FROM $config[sql_check_table] WHERE username = '$login';");
                if ($res){
                        $res = da_sql_query($link,$config,
                                "DELETE FROM $config[sql_usergroup_table] WHERE username = '$login';");
                        if (!$res)
                                echo "<b>Error deleting user $login from user group table: " . da_sql_error($link,$config) . "</b><br>\n";
                        if ($config['sql_use_user_info_table'] == 'true'){
                                $res = da_sql_query($link,$config,
                                "DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
                                if ($res) {
                                        echo "<b>$l_user $login $l_removed</b><br>\n";

                                        if (preg_match('/^([a-fA-F0-9]{2}[:|\-]?){6}$/', $login)) {
                                                $user_ip = exec('sudo chilli_query list | grep '.escapeshellarg($login)." |  cut -d' ' -f2");
                                                //on vérifie que l'@IP de l'@MAC est différente de celle de l'admin sur l'ACC
                                                if ((!empty($user_ip)) && ($user_ip !== $_SERVER['REMOTE_ADDR'])) {
                                                        exec('sudo chilli_query logout '.escapeshellarg($login));
                                                }
                                        }
                                }
                                else
                                        echo "<b>Error deleting user $login from user info table: " . da_sql_error($link,$config) . "</b><br>\n";
                        }
                }
                else
                        echo "<b>Error deleting user $login from check table: " . da_sql_error($link,$config) . "</b><br>\n";
        }
        else
                echo "<b>Error deleting user $login from reply table: " . da_sql_error($link,$config) . "</b><br>\n";
}
else
        echo "<b>Could not connect to SQL database</b><br>\n";
?>