2 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
3 include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
5 echo "<b>Could not include SQL library</b><br>\n";
8 include_once('../lib/functions.php3');
9 if ($config[sql_use_operators] == 'true'){
10 include("../lib/operators.php3");
15 $link = @da_sql_pconnect($config);
17 if (is_file("../lib/crypt/$config[general_encryption_method].php3")){
18 include("../lib/crypt/$config[general_encryption_method].php3");
19 $passwd = da_encrypt($passwd);
20 $res = @da_sql_query($link,$config,
21 "INSERT INTO $config[sql_check_table] (attribute,value,username $text)
22 VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
23 if (!$res || !@da_sql_affected_rows($link,$res,$config)){
24 echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
27 if ($config[sql_use_user_info_table] == 'true' && !$da_abort){
28 $res = @da_sql_query($link,$config,
29 "SELECT username FROM $config[sql_user_info_table] WHERE
30 username = '$login';");
32 if (!@da_sql_num_rows($res,$config)){
33 $Fcn = da_sql_escape_string($Fcn);
34 $Fmail = da_sql_escape_string($Fmail);
35 $Fou = da_sql_escape_string($Fou);
36 $Fhomephone = da_sql_escape_string($Fhomephone);
37 $Fworkphone = da_sql_escape_string($Fworkphone);
38 $Fmobile = da_sql_escape_string($Fmobile);
39 $res = @da_sql_query($link,$config,
40 "INSERT INTO $config[sql_user_info_table]
41 (username,name,mail,department,homephone,workphone,mobile) VALUES
42 ('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
43 if (!$res || !@da_sql_affected_rows($link,$res,$config))
44 echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
47 echo "<b>User already exists in user info table.</b><br>\n";
50 echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
53 $Fgroup = da_sql_escape_string($Fgroup);
54 $res = @da_sql_query($link,$config,
55 "SELECT username FROM $config[sql_usergroup_table]
56 WHERE username = '$login' AND groupname = '$Fgroup';");
58 if (!@da_sql_num_rows($res,$config)){
59 $res = @da_sql_query($link,$config,
60 "INSERT INTO $config[sql_usergroup_table]
61 (username,groupname) VALUES ('$login','$Fgroup');");
62 if (!$res || !@da_sql_affected_rows($link,$res,$config))
63 echo "<b>Could not add user to group $Fgroup. SQL Error</b><br>\n";
66 echo "<b>User already is a member of group $Fgroup</b><br>\n";
69 echo "<b>Could not add user to group $Fgroup: " . da_sql_error($link,$config) . "</b><br>\n";
73 require('../lib/defaults.php3');
74 foreach($show_attrs as $key => $attr){
75 if ($attrmap["$key"] == 'none')
77 if ($attrmap["$key"] == ''){
78 $attrmap["$key"] = $key;
79 $attr_type["$key"] = 'replyItem';
80 $rev_attrmap["$key"] = $key;
82 if ($attr_type["$key"] == 'checkItem'){
83 $table = "$config[sql_check_table]";
86 else if ($attr_type["$key"] == 'replyItem'){
87 $table = "$config[sql_reply_table]";
90 $val = $$attrmap["$key"];
91 $val = da_sql_escape_string($val);
92 $op_name = $attrmap["$key"] . '_op';
95 if (check_operator($op_val,$type) == -1){
96 echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
99 $op_val2 = ",'$op_val'";
101 if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
103 $res = @da_sql_query($link,$config,
104 "INSERT INTO $table (attribute,value,username $text)
105 VALUES ('$attrmap[$key]','$val','$login' $op_val2);");
106 if (!$res || !@da_sql_affected_rows($link,$res,$config))
107 echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
110 echo "<b>User created successfully</b><br>\n";
113 echo "<b>Could not open encryption library file</b><br>\n";
116 echo "<b>Could not connect to SQL database</b><br>\n";