Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1805 clement.si 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
$link = da_sql_pconnect($config);
9
$fail = 0;
10
if ($link){
11
	if ($config['sql_use_user_info_table'] == 'true'){
12
		$res = da_sql_query($link,$config,
13
		"SELECT username FROM $config[sql_user_info_table] WHERE
14
		username = '$login';");
15
		if ($res){
16
			$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
17
			$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
18
			$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
19
			$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
20
			$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
21
			$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
22
 
23
			if (!da_sql_num_rows($res,$config)){
24
				$res = da_sql_query($link,$config,
25
				"INSERT INTO $config[sql_user_info_table]
26
				(username,name,mail,department,homephone,workphone,mobile) VALUES
27
				('$login','$Fcn','$Fmail','$Fou','$Ftelephonenumber','$Fhomephone','$Fmobile');");
28
				if (!$res || !da_sql_affected_rows($link,$res,$config)){
29
					echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
30
					$fail = 1;
31
				}
32
			}
33
			else{
34
				$res = da_sql_query($link,$config,
35
				"UPDATE $config[sql_user_info_table] SET name = '$Fcn',Mail = '$Fmail',
36
				department = '$Fou', homephone = '$Fhomephone', workphone = '$Ftelephonenumber',
37
				mobile = '$Fmobile' WHERE username = '$login';");
38
				if (!$res || !da_sql_affected_rows($link,$res,$config)){
39
					echo "<b>Could not update user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
40
					$fail = 1;
41
				}
42
			}
43
		}
44
		else{
45
			echo "<b>Could not find user in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
46
			$fail = 1;
47
		}
48
		if ($fail == 0)
49
			echo "<b>User information updated successfully</b><br>\n";
50
	}
51
	else
52
		echo "<b>Cannot use the user info table. Check the sql_use_user_info_table directive in admin.conf</b><br>\n";
53
 
54
}
55
else
56
	echo "<b>Could not connect to SQL database</b><br>\n";
57
?>