1 |
<?php
|
1 |
<?php
|
2 |
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
|
2 |
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
|
3 |
include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
|
3 |
include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
|
4 |
else{
|
4 |
else{
|
5 |
echo "<b>Could not include SQL library</b><br>\n";
|
5 |
echo "<b>Could not include SQL library</b><br>\n";
|
6 |
exit();
|
6 |
exit();
|
7 |
}
|
7 |
}
|
8 |
$link = da_sql_pconnect($config);
|
8 |
$link = da_sql_pconnect($config);
|
9 |
if ($link){
|
9 |
if ($link){
|
10 |
$res = da_sql_query($link,$config,
|
10 |
$res = da_sql_query($link,$config,
|
11 |
"DELETE FROM $config[sql_reply_table] WHERE username = '$login';");
|
11 |
"DELETE FROM $config[sql_reply_table] WHERE username = '$login';");
|
12 |
if ($res){
|
12 |
if ($res){
|
13 |
$res = da_sql_query($link,$config,
|
13 |
$res = da_sql_query($link,$config,
|
14 |
"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
|
14 |
"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
|
15 |
if ($res){
|
15 |
if ($res){
|
16 |
$res = da_sql_query($link,$config,
|
16 |
$res = da_sql_query($link,$config,
|
17 |
"DELETE FROM $config[sql_usergroup_table] WHERE username = '$login';");
|
17 |
"DELETE FROM $config[sql_usergroup_table] WHERE username = '$login';");
|
18 |
if (!$res)
|
18 |
if (!$res)
|
19 |
echo "<b>Error deleting user $login from user group table: " . da_sql_error($link,$config) . "</b><br>\n";
|
19 |
echo "<b>Error deleting user $login from user group table: " . da_sql_error($link,$config) . "</b><br>\n";
|
20 |
if ($config['sql_use_user_info_table'] == 'true'){
|
20 |
if ($config['sql_use_user_info_table'] == 'true'){
|
21 |
$res = da_sql_query($link,$config,
|
21 |
$res = da_sql_query($link,$config,
|
22 |
"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
|
22 |
"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
|
23 |
if ($res) {
|
23 |
if ($res) {
|
24 |
echo "<b>$l_user $login $l_removed</b><br>\n";
|
24 |
echo "<b>$l_user $login $l_removed</b><br>\n";
|
25 |
|
25 |
|
26 |
if (preg_match('/^([a-fA-F0-9]{2}[:|\-]?){6}$/', $login)) {
|
26 |
if (preg_match('/^([a-fA-F0-9]{2}[:|\-]?){6}$/', $login)) {
|
27 |
$user_ip = exec('sudo chilli_query list | grep '.escapeshellarg($login)." | cut -d' ' -f2");
|
27 |
$user_ip = exec('sudo /usr/sbin/chilli_query list | awk '.escapeshellarg('($5 == 1) && ($6 == "'.$login.'") {print $2}'));
|
28 |
//on vérifie que l'@IP de l'@MAC est différente de celle de l'admin sur l'ACC
|
28 |
//on vérifie que l'@IP de l'@MAC est différente de celle de l'admin sur l'ACC
|
29 |
if ((!empty($user_ip)) && ($user_ip !== $_SERVER['REMOTE_ADDR'])) {
|
29 |
if ((!empty($user_ip)) && ($user_ip !== $_SERVER['REMOTE_ADDR'])) {
|
30 |
exec('sudo chilli_query logout '.escapeshellarg($login));
|
30 |
exec('sudo /usr/sbin/chilli_query logout mac '.escapeshellarg($login));
|
31 |
}
|
31 |
}
|
32 |
}
|
32 |
}
|
33 |
}
|
33 |
}
|
34 |
else
|
34 |
else
|
35 |
echo "<b>Error deleting user $login from user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
35 |
echo "<b>Error deleting user $login from user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
36 |
}
|
36 |
}
|
37 |
}
|
37 |
}
|
38 |
else
|
38 |
else
|
39 |
echo "<b>Error deleting user $login from check table: " . da_sql_error($link,$config) . "</b><br>\n";
|
39 |
echo "<b>Error deleting user $login from check table: " . da_sql_error($link,$config) . "</b><br>\n";
|
40 |
}
|
40 |
}
|
41 |
else
|
41 |
else
|
42 |
echo "<b>Error deleting user $login from reply table: " . da_sql_error($link,$config) . "</b><br>\n";
|
42 |
echo "<b>Error deleting user $login from reply table: " . da_sql_error($link,$config) . "</b><br>\n";
|
43 |
}
|
43 |
}
|
44 |
else
|
44 |
else
|
45 |
echo "<b>Could not connect to SQL database</b><br>\n";
|
45 |
echo "<b>Could not connect to SQL database</b><br>\n";
|
46 |
?>
|
46 |
?>
|
47 |
|
47 |
|