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