Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
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($del_members)){
11
		foreach ($del_members as $del){
12
			$del = da_sql_escape_string($link, $del);
13
			$res = da_sql_query($link,$config,
14
			"DELETE FROM $config[sql_usergroup_table] WHERE username = '$del' AND groupname = '$login';");
15
			if (!$res)
16
				echo "<b>Could not delete user $del from group: " . da_sql_error($link,$config) . "</b><br>\n";
17
		}
18
	}
19
	if ($new_members != ''){
20
		$Members = preg_split("/[\n\s]+/",$new_members,-1,PREG_SPLIT_NO_EMPTY);
21
		if (!empty($Members)){
22
			foreach ($Members as $new_member){
23
				$new_member = da_sql_escape_string($link, $new_member);
24
				$res = da_sql_query($link,$config,
25
				"SELECT username FROM $config[sql_usergroup_table] WHERE
26
				username = '$new_member' AND groupname = '$login';");
27
				if ($res){
28
					if (da_sql_num_rows($res,$config))
29
						echo "<b>User $new_member already is a member of the group</b><br>\n";
30
					else{
31
						$res = da_sql_query($link,$config,
32
						"INSERT INTO $config[sql_usergroup_table] (groupname,username)
33
						VALUES ('$login','$new_member');");
34
						if (!$res)
35
							echo "<b>Error while adding user $new_member to group: " . da_sql_error($link,$config) . "</b><br>\n";
36
					}
37
				}
38
				else
39
					echo "<b>Could not add new member $new_member: " . da_sql_error($link,$config) . "</b><br>\n";
40
			}
41
		}
42
	}
43
}
44
else
45
	echo "<b>Could not connect to SQL database</b><br>\n";
46
?>