Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
|
2 |
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
|
3 |
include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
|
3 |
include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
|
4 |
else{
|
4 |
else{
|
5 |
echo "<b>Could not include SQL library</b><br>\n";
|
5 |
echo "<b>Could not include SQL library</b><br>\n";
|
6 |
exit();
|
6 |
exit();
|
7 |
}
|
7 |
}
|
8 |
include_once('../lib/functions.php');
|
8 |
include_once('../lib/functions.php');
|
9 |
if ($config[sql_use_operators] == 'true'){
|
9 |
if ($config['sql_use_operators'] == 'true'){
|
10 |
include_once("../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 |
if (is_file("../lib/crypt/$config[general_encryption_method].php")){
|
18 |
if (is_file("../lib/crypt/$config[general_encryption_method].php")){
|
19 |
include_once("../lib/crypt/$config[general_encryption_method].php");
|
19 |
include_once("../lib/crypt/$config[general_encryption_method].php");
|
20 |
/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
|
20 |
/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
|
21 |
$passwd_imp = $passwd;
|
21 |
$passwd_imp = $passwd;
|
22 |
/*Fin Ajout*/
|
22 |
/*Fin Ajout*/
|
23 |
$passwd = da_encrypt($passwd);
|
23 |
$passwd = da_encrypt($passwd);
|
24 |
$passwd = da_sql_escape_string($passwd);
|
24 |
$passwd = da_sql_escape_string($link, $passwd);
|
25 |
$res = @da_sql_query($link,$config,
|
25 |
$res = da_sql_query($link,$config,
|
26 |
"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
|
26 |
"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
|
27 |
VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
|
27 |
VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
|
28 |
if (!$res || !@da_sql_affected_rows($link,$res,$config)){
|
28 |
if (!$res || !da_sql_affected_rows($link,$res,$config)){
|
29 |
echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
|
29 |
echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
|
30 |
$da_abort=1;
|
30 |
$da_abort=1;
|
31 |
}
|
31 |
}
|
32 |
if ($config[sql_use_user_info_table] == 'true' && !$da_abort){
|
32 |
if ($config['sql_use_user_info_table'] == 'true' && !$da_abort){
|
33 |
$res = @da_sql_query($link,$config,
|
33 |
$res = da_sql_query($link,$config,
|
34 |
"SELECT username FROM $config[sql_user_info_table] WHERE
|
34 |
"SELECT username FROM $config[sql_user_info_table] WHERE
|
35 |
username = '$login';");
|
35 |
username = '$login';");
|
36 |
if ($res){
|
36 |
if ($res){
|
37 |
if (!@da_sql_num_rows($res,$config)){
|
37 |
if (!da_sql_num_rows($res,$config)){
|
38 |
$Fcn = da_sql_escape_string($Fcn);
|
38 |
$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
|
39 |
$Fmail = da_sql_escape_string($Fmail);
|
39 |
$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
|
40 |
$Fou = da_sql_escape_string($Fou);
|
40 |
$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
|
41 |
$Fhomephone = da_sql_escape_string($Fhomephone);
|
41 |
$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
|
42 |
$Fworkphone = da_sql_escape_string($Fworkphone);
|
42 |
$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
|
43 |
$Fmobile = da_sql_escape_string($Fmobile);
|
43 |
$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
|
44 |
$res = @da_sql_query($link,$config,
|
44 |
$res = da_sql_query($link,$config,
|
45 |
"INSERT INTO $config[sql_user_info_table]
|
45 |
"INSERT INTO $config[sql_user_info_table]
|
46 |
(username,name,mail,department,homephone,workphone,mobile) VALUES
|
46 |
(username,name,mail,department,homephone,workphone,mobile) VALUES
|
47 |
('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
|
47 |
('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
|
48 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
48 |
if (!$res || !da_sql_affected_rows($link,$res,$config))
|
49 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
49 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
50 |
}
|
50 |
}
|
51 |
else
|
51 |
else
|
52 |
echo "<b>Cet usager existe déjà dans la table 'info'</b><br>\n";
|
52 |
echo "<b>Cet usager existe déjà dans la table 'info'</b><br>\n";
|
53 |
}
|
53 |
}
|
54 |
else
|
54 |
else
|
55 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
55 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
56 |
}
|
56 |
}
|
57 |
if ($Fgroup != ''){
|
57 |
if (isset($Fgroup) && $Fgroup != ''){
|
58 |
$Fgroup = da_sql_escape_string($Fgroup);
|
58 |
$Fgroup = da_sql_escape_string($link, $Fgroup);
|
59 |
$res = @da_sql_query($link,$config,
|
59 |
$res = da_sql_query($link,$config,
|
60 |
"SELECT username FROM $config[sql_usergroup_table]
|
60 |
"SELECT username FROM $config[sql_usergroup_table]
|
61 |
WHERE username = '$login' AND groupname = '$Fgroup';");
|
61 |
WHERE username = '$login' AND groupname = '$Fgroup';");
|
62 |
if ($res){
|
62 |
if ($res){
|
63 |
if (!@da_sql_num_rows($res,$config)){
|
63 |
if (!da_sql_num_rows($res,$config)){
|
64 |
$res = @da_sql_query($link,$config,
|
64 |
$res = da_sql_query($link,$config,
|
65 |
"INSERT INTO $config[sql_usergroup_table]
|
65 |
"INSERT INTO $config[sql_usergroup_table]
|
66 |
(username,groupname) VALUES ('$login','$Fgroup');");
|
66 |
(username,groupname) VALUES ('$login','$Fgroup');");
|
67 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
67 |
if (!$res || !da_sql_affected_rows($link,$res,$config))
|
68 |
echo "<b>Could not add user to group $Fgroup. SQL Error</b><br>\n";
|
68 |
echo "<b>Could not add user to group $Fgroup. SQL Error</b><br>\n";
|
69 |
}
|
69 |
}
|
70 |
else
|
70 |
else
|
71 |
echo "<b>User already is a member of group $Fgroup</b><br>\n";
|
71 |
echo "<b>User already is a member of group $Fgroup</b><br>\n";
|
72 |
}
|
72 |
}
|
73 |
else
|
73 |
else
|
74 |
echo "<b>Could not add user to group $Fgroup: " . da_sql_error($link,$config) . "</b><br>\n";
|
74 |
echo "<b>Could not add user to group $Fgroup: " . da_sql_error($link,$config) . "</b><br>\n";
|
75 |
}
|
75 |
}
|
76 |
if (!$da_abort){
|
76 |
if (!$da_abort){
|
77 |
if ($Fgroup != '')
|
77 |
if (isset($Fgroup) && $Fgroup != '')
|
78 |
require('../lib/defaults.php');
|
78 |
require('../lib/defaults.php');
|
79 |
foreach($show_attrs as $key => $attr){
|
79 |
foreach($show_attrs as $key => $attr){
|
80 |
if ($attrmap["$key"] == 'none')
|
80 |
if ($attrmap["$key"] == 'none')
|
81 |
continue;
|
81 |
continue;
|
82 |
if ($key == "Filter-Id" && $$attrmap["$key"] == "None")
|
82 |
if ($key == "Filter-Id" && $$attrmap["$key"] == "None")
|
Line 84... |
Line 84... |
84 |
if ($attrmap["$key"] == ''){
|
84 |
if ($attrmap["$key"] == ''){
|
85 |
$attrmap["$key"] = $key;
|
85 |
$attrmap["$key"] = $key;
|
86 |
$attr_type["$key"] = 'replyItem';
|
86 |
$attr_type["$key"] = 'replyItem';
|
87 |
$rev_attrmap["$key"] = $key;
|
87 |
$rev_attrmap["$key"] = $key;
|
88 |
}
|
88 |
}
|
89 |
if ($attr_type["$key"] == 'checkItem'){
|
89 |
if (isset($attr_type["$key"]) && $attr_type["$key"] == 'checkItem'){
|
90 |
$table = "$config[sql_check_table]";
|
90 |
$table = "$config[sql_check_table]";
|
91 |
$type = 1;
|
91 |
$type = 1;
|
92 |
}
|
92 |
}
|
93 |
else if ($attr_type["$key"] == 'replyItem'){
|
93 |
else if (isset($attr_type["$key"]) && $attr_type["$key"] == 'replyItem'){
|
94 |
$table = "$config[sql_reply_table]";
|
94 |
$table = "$config[sql_reply_table]";
|
95 |
$type = 2;
|
95 |
$type = 2;
|
96 |
}
|
96 |
}
|
97 |
$val = $$attrmap["$key"];
|
97 |
$val = (isset($$attrmap["$key"])) ? $$attrmap["$key"] : '';
|
98 |
/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
|
98 |
/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
|
99 |
if($key == "Session-Timeout") $sto_imp = $val;
|
99 |
if($key == "Session-Timeout") $sto_imp = $val;
|
100 |
if($key == "Max-All-Session") $mas_imp = $val;
|
100 |
if($key == "Max-All-Session") $mas_imp = $val;
|
101 |
if($key == "Max-Daily-Session") $mds_imp = $val;
|
101 |
if($key == "Max-Daily-Session") $mds_imp = $val;
|
102 |
if($key == "Max-Monthly-Session") $mms_imp = $val;
|
102 |
if($key == "Max-Monthly-Session") $mms_imp = $val;
|
103 |
/*Fin Ajout*/
|
103 |
/*Fin Ajout*/
|
104 |
$val = da_sql_escape_string($val);
|
104 |
$val = da_sql_escape_string($link, $val);
|
105 |
$op_name = $attrmap["$key"] . '_op';
|
105 |
$op_name = $attrmap["$key"] . '_op';
|
106 |
$op_val = $$op_name;
|
106 |
$op_val = (isset($$op_name)) ? $$op_name : '';
|
107 |
if ($op_val != ''){
|
107 |
if ($op_val != ''){
|
108 |
$op_val = da_sql_escape_string($op_val);
|
108 |
$op_val = da_sql_escape_string($link, $op_val);
|
109 |
if (check_operator($op_val,$type) == -1){
|
109 |
if (check_operator($op_val,$type) == -1){
|
110 |
echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
|
110 |
echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
|
111 |
continue;
|
111 |
continue;
|
112 |
}
|
112 |
}
|
113 |
$op_val2 = ",'$op_val'";
|
113 |
$op_val2 = ",'$op_val'";
|
114 |
}
|
114 |
}
|
115 |
if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
|
115 |
$chkdef = (isset($default_vals["$key"])) ? check_defaults($val,$op_val,$default_vals["$key"]) : 0;
|
- |
|
116 |
if ($val == '' || $chkdef)
|
116 |
continue;
|
117 |
continue;
|
117 |
$res = @da_sql_query($link,$config,
|
- |
|
118 |
"INSERT INTO $table (attribute,value,username $text)
|
118 |
$sqlquery = "INSERT INTO $table (attribute,value,username $text)
|
119 |
VALUES ('$attrmap[$key]','$val','$login' $op_val2);");
|
119 |
VALUES ('$attrmap[$key]','$val','$login' $op_val2);";
|
- |
|
120 |
$res = da_sql_query($link,$config,$sqlquery);
|
120 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
121 |
if (!$res || !da_sql_affected_rows($link,$res,$config))
|
121 |
echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
|
122 |
echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
|
122 |
}
|
123 |
}
|
123 |
}
|
124 |
}
|
124 |
echo "<b>Usager correctement créé</b><br>\n";
|
125 |
echo "<b>Usager correctement créé</b><br>\n";
|
125 |
}
|
126 |
}
|