Subversion Repositories ALCASAR

Rev

Rev 1377 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1377 Rev 1805
Line 4... Line 4...
4
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
4
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
5
else{
5
else{
6
	echo "<b>Could not include SQL library</b><br>\n";
6
	echo "<b>Could not include SQL library</b><br>\n";
7
	exit();
7
	exit();
8
}
8
}
9
if ($config[sql_use_operators] == 'true'){
9
if ($config['sql_use_operators'] == 'true'){
10
	include("../lib/operators.php");
10
	include_once("../lib/operators.php");
11
	$text = ',op';
11
	$text = ',op';
12
	$passwd_op = ",':='";
12
	$passwd_op = ",':='";
13
}
13
}
14
$da_abort=0;
14
$da_abort=0;
15
$op_val2 = '';
15
$op_val2 = '';
16
$link = @da_sql_pconnect($config);
16
$link = da_sql_pconnect($config);
17
if ($link){
17
if ($link){
18
	$Members = preg_split("/[\n\s]+/",$members,-1,PREG_SPLIT_NO_EMPTY);
18
	$Members = preg_split("/[\n\s]+/",$members,-1,PREG_SPLIT_NO_EMPTY);
19
	if (!empty($Members)){
19
	if (!empty($Members)){
20
		foreach ($Members as $member){
20
		foreach ($Members as $member){
21
			$member = da_sql_escape_string($member);
21
			$member = da_sql_escape_string($link, $member);
22
			$res = @da_sql_query($link,$config,
22
			$res = da_sql_query($link,$config,
23
			"INSERT INTO $config[sql_usergroup_table] (username,groupname)
23
			"INSERT INTO $config[sql_usergroup_table] (username,groupname)
24
			VALUES ('$member','$login');");
24
			VALUES ('$member','$login');");
25
			if (!$res || !@da_sql_affected_rows($link,$res,$config)){
25
			if (!$res || !da_sql_affected_rows($link,$res,$config)){
26
				echo "<b>Unable to add user $member in group $login: " . da_sql_error($link,$config) . "</b><br>\n";
26
				echo "<b>Unable to add user $member in group $login: " . da_sql_error($link,$config) . "</b><br>\n";
27
				$da_abort=1;
27
				$da_abort=1;
28
			}
28
			}
29
		}
29
		}
30
	}
30
	}
31
	else
31
	else
32
		{
32
		{
33
		$res = @da_sql_query($link,$config,
33
		$res = da_sql_query($link,$config,
34
			"INSERT INTO $config[sql_usergroup_table] (username,groupname)
34
			"INSERT INTO $config[sql_usergroup_table] (username,groupname)
35
			VALUES ('$login','$login');");
35
			VALUES ('$login','$login');");
36
			if (!$res || !@da_sql_affected_rows($link,$res,$config))
36
			if (!$res || !da_sql_affected_rows($link,$res,$config))
37
				{
37
				{
38
				echo "<b>Unable to add user $member in group $login: " . da_sql_error($link,$config) . "</b><br>\n";
38
				echo "<b>Unable to add user $member in group $login: " . da_sql_error($link,$config) . "</b><br>\n";
39
				$da_abort=1;
39
				$da_abort=1;
40
				}
40
				}
41
			else
41
			else
Line 53... Line 53...
53
			if ($attrmap["$key"] == ''){
53
			if ($attrmap["$key"] == ''){
54
				$attrmap["$key"] = $key;
54
				$attrmap["$key"] = $key;
55
				$attr_type["$key"] = 'replyItem';
55
				$attr_type["$key"] = 'replyItem';
56
				$rev_attrmap["$key"] = $key;
56
				$rev_attrmap["$key"] = $key;
57
			}
57
			}
58
			if ($attr_type["$key"] == 'checkItem'){
58
			if (isset($attr_type["$key"]) && $attr_type["$key"] == 'checkItem'){
59
				$table = "$config[sql_groupcheck_table]";
59
				$table = "$config[sql_groupcheck_table]";
60
				$type = 1;
60
				$type = 1;
61
			}
61
			}
62
			else if ($attr_type["$key"] == 'replyItem'){
62
			else if (isset($attr_type["$key"]) && $attr_type["$key"] == 'replyItem'){
63
				$table = "$config[sql_groupreply_table]";
63
				$table = "$config[sql_groupreply_table]";
64
				$type = 2;
64
				$type = 2;
65
			}
65
			}
66
			$val = $$attrmap["$key"];
66
			$val = $$attrmap["$key"];
67
			$val = da_sql_escape_string($val);
67
			$val = da_sql_escape_string($link, $val);
68
			$op_name = $attrmap["$key"] . '_op';
68
			$op_name = $attrmap["$key"] . '_op';
69
			$op_val = $$op_name;
69
			$op_val = $$op_name;
70
			if ($op_val != ''){
70
			if ($op_val != ''){
71
				$op_val = da_sql_escape_string($op_val);
71
				$op_val = da_sql_escape_string($link, $op_val);
72
				if (check_operator($op_val,$type) == -1){
72
				if (check_operator($op_val,$type) == -1){
73
					echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
73
					echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
74
					coninue;
74
					coninue;
75
				}
75
				}
76
				$op_val2 = ",'$op_val'";
76
				$op_val2 = ",'$op_val'";
77
			}
77
			}
78
			if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
78
			$chkdef = (isset($default_vals["$key"])) ? check_defaults($val,$op_val,$default_vals["$key"]) : 0;
-
 
79
			if ($val == '' || $chkdef)
79
				continue;
80
				continue;
80
			$res = @da_sql_query($link,$config,
81
			$res = da_sql_query($link,$config,
81
			"INSERT INTO $table (attribute,value,groupname $text)
82
			"INSERT INTO $table (attribute,value,groupname $text)
82
			VALUES ('$attrmap[$key]','$val','$login' $op_val2);");
83
			VALUES ('$attrmap[$key]','$val','$login' $op_val2);");
83
			if (!$res || !@da_sql_affected_rows($link,$res,$config))
84
			if (!$res || !da_sql_affected_rows($link,$res,$config))
84
				echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
85
				echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
85
		}
86
		}
86
		echo "<b>Le groupe $login a &eacute;t&eacute; correctement cr&eacute;&eacute;</b><br>\n";
87
		echo "<b>Le groupe $login a &eacute;t&eacute; correctement cr&eacute;&eacute;</b><br>\n";
87
	}
88
	}
88
}
89
}