1805 |
clement.si |
1 |
<?php
|
|
|
2 |
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
|
|
|
3 |
include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
|
|
|
4 |
else{
|
|
|
5 |
echo "<b>Could not include SQL library</b><br>\n";
|
|
|
6 |
exit();
|
|
|
7 |
}
|
|
|
8 |
$link = da_sql_pconnect($config);
|
|
|
9 |
if ($link){
|
|
|
10 |
if (isset($member_groups) && isset($edited_groups)){
|
|
|
11 |
$del_groups = array_diff($member_groups,$edited_groups);
|
|
|
12 |
if (isset($del_groups)){
|
|
|
13 |
foreach ($del_groups as $del){
|
|
|
14 |
$del = da_sql_escape_string($del);
|
|
|
15 |
$res = da_sql_query($link,$config,
|
|
|
16 |
"DELETE FROM $config[sql_usergroup_table] WHERE username = '$login' AND groupname = '$del';");
|
|
|
17 |
if (!$res)
|
|
|
18 |
echo "<b>Could not delete user $login from group $del: " . da_sql_error($link,$config) . "</b><br>\n";
|
|
|
19 |
else
|
|
|
20 |
echo "<b>User $login deleted from group $del</b><br>\n";
|
|
|
21 |
}
|
|
|
22 |
}
|
|
|
23 |
$new_groups = array_diff($edited_groups,$member_groups);
|
|
|
24 |
if (isset($new_groups)){
|
|
|
25 |
foreach($new_groups as $new){
|
|
|
26 |
$new = da_sql_escape_string($new);
|
|
|
27 |
$res = da_sql_query($link,$config,
|
|
|
28 |
"INSERT INTO $config[sql_usergroup_table] (groupname,username)
|
|
|
29 |
VALUES ('$new','$login');");
|
|
|
30 |
if (!$res)
|
|
|
31 |
echo "<b>Error while adding user $login to group $login: " . da_sql_error($link,$config) . "</b><br>\n";
|
|
|
32 |
else
|
|
|
33 |
echo "<b>User $login added to group $new</b><br>\n";
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
else
|
|
|
39 |
echo "<b>Could not connect to SQL database</b><br>\n";
|
|
|
40 |
?>
|