Subversion Repositories ALCASAR

Rev

Rev 325 | Rev 509 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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