Subversion Repositories ALCASAR

Rev

Rev 1879 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1879 Rev 2333
1
<?php
1
<?php
2
require('../lib/sql/attrmap.php');
2
require('../lib/sql/attrmap.php');
3
if (is_file("../lib/sql/drivers/$config[sql_type]/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");
4
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
5
else{
5
else{
6
	echo "<b>Could not include SQL library</b><br>\n";
6
	echo "<b>Could not include SQL library</b><br>\n";
7
	exit();
7
	exit();
8
}
8
}
9
if ($config['sql_use_operators'] == 'true'){
9
if ($config['sql_use_operators'] == 'true'){
10
	$op = ',op';
10
	$op = ',op';
11
	$use_op = 1;
11
	$use_op = 1;
12
}else{
12
}else{
13
	$op = "";
13
	$op = "";
14
	$use_op = 0;
14
	$use_op = 0;
15
}
15
}
16
$user_exists = 'no';
16
$user_exists = 'no';
17
 
17
 
18
$cn = '-';
18
$cn = '-';
19
$cn_lang = '-';
19
$cn_lang = '-';
20
$address = '-';
20
$address = '-';
21
$address_lang = '-';
21
$address_lang = '-';
22
$homeaddress = '-';
22
$homeaddress = '-';
23
$homeaddress_lang = '-';
23
$homeaddress_lang = '-';
24
$fax = '-';
24
$fax = '-';
25
$url = '-';
25
$url = '-';
26
$ou = '-';
26
$ou = '-';
27
$ou_lang = '-';
27
$ou_lang = '-';
28
$title = '-';
28
$title = '-';
29
$title_lang = '-';
29
$title_lang = '-';
30
$telephonenumber = '-';
30
$telephonenumber = '-';
31
$homephone = '-';
31
$homephone = '-';
32
$mobile = '-';
32
$mobile = '-';
33
$mail = '-';
33
$mail = '-';
34
$mailalt = '-';
34
$mailalt = '-';
35
$user_password_exists = 'no';
35
$user_password_exists = 'no';
36
 
36
 
37
if(!isset($login)) $login ='';
37
if(!isset($login)) $login ='';
38
 
38
 
39
unset($item_vals);
39
unset($item_vals);
40
unset($tmp);
40
unset($tmp);
41
$link = da_sql_pconnect($config);
41
$link = da_sql_pconnect($config);
42
if ($link){
42
if ($link){
43
	$res = da_sql_query($link,$config,
43
	$res = da_sql_query($link,$config,
44
	"SELECT attribute,value $op FROM $config[sql_check_table] WHERE username = '$login';");
44
	"SELECT attribute,value $op FROM $config[sql_check_table] WHERE username = '$login';");
45
	if ($res){
45
	if ($res){
46
		if (da_sql_num_rows($res,$config))
46
		if (da_sql_num_rows($res,$config))
47
			$user_exists = 'yes';
47
			$user_exists = 'yes';
48
		while(($row = da_sql_fetch_array($res,$config))){
48
		while(($row = da_sql_fetch_array($res,$config))){
49
			$attr = $row['attribute'];
49
			$attr = $row['attribute'];
50
			$val = $row['value'];
50
			$val = $row['value'];
51
			if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
51
			if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
52
			if ($attr == $config['sql_password_attribute'] && $val != '')
52
			if ($attr == $config['sql_password_attribute'] && $val != '')
53
				$user_password_exists = 'yes';
53
				$user_password_exists = 'yes';
54
			if ($use_op){
54
			if ($use_op){
55
				$oper = $row['op'];
55
				$oper = $row['op'];
56
				$tmp["$attr"]['operator'][]="$oper";
56
				$tmp["$attr"]['operator'][]="$oper";
57
			}
57
			}
58
			$tmp["$attr"][]="$val";
58
			$tmp["$attr"][]="$val";
59
			$tmp["$attr"]['count']++;
59
			$tmp["$attr"]['count']++;
60
		}
60
		}
61
		$res = da_sql_query($link,$config,
61
		$res = da_sql_query($link,$config,
62
		"SELECT attribute,value $op FROM $config[sql_reply_table] WHERE username = '$login';");
62
		"SELECT attribute,value $op FROM $config[sql_reply_table] WHERE username = '$login';");
63
		if ($res){
63
		if ($res){
64
			if (da_sql_num_rows($res,$config))
64
			if (da_sql_num_rows($res,$config))
65
				$user_exists = 'yes';
65
				$user_exists = 'yes';
66
			while(($row = da_sql_fetch_array($res,$config))){
66
			while(($row = da_sql_fetch_array($res,$config))){
67
				$attr = $row['attribute'];
67
				$attr = $row['attribute'];
68
				$val = $row['value'];
68
				$val = $row['value'];
69
				if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
69
				if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
70
				if ($use_op){
70
				if ($use_op){
71
					$oper = $row['op'];
71
					$oper = $row['op'];
72
					$tmp["$attr"]['operator'][]="$oper";
72
					$tmp["$attr"]['operator'][]="$oper";
73
				}
73
				}
74
				$tmp["$attr"][] = "$val";
74
				$tmp["$attr"][] = "$val";
75
				$tmp["$attr"]['count']++;
75
				$tmp["$attr"]['count']++;
76
			}
76
			}
77
			if ($config['sql_use_user_info_table'] == 'true'){
77
			if ($config['sql_use_user_info_table'] == 'true'){
78
				$res = da_sql_query($link,$config,
78
				$res = da_sql_query($link,$config,
79
				"SELECT * FROM $config[sql_user_info_table] WHERE username = '$login';");
79
				"SELECT * FROM $config[sql_user_info_table] WHERE username = '$login';");
80
				if ($res){
80
				if ($res){
81
					if (da_sql_num_rows($res,$config)){
81
					if (da_sql_num_rows($res,$config)){
82
						$user_exists = 'yes';
82
						$user_exists = 'yes';
83
						$user_info = 1;
83
						$user_info = 1;
84
					}
84
					}
85
					if (($row = da_sql_fetch_array($res,$config))){
85
					if (($row = da_sql_fetch_array($res,$config))){
86
						$cn = ($row['name'] != '') ? $row['name'] : '-';
86
						$cn = ($row['name'] != '') ? $row['name'] : '-';
87
						$telephonenumber = ($row['workphone'] != '') ? $row['workphone'] : '-';
87
						$telephonenumber = ($row['workphone'] != '') ? $row['workphone'] : '-';
88
						$homephone = ($row['homephone'] != '') ? $row['homephone'] : '-';
88
						$homephone = ($row['homephone'] != '') ? $row['homephone'] : '-';
89
						$ou = ($row['department'] != '') ? $row['department'] : '-';
89
						$ou = ($row['department'] != '') ? $row['department'] : '-';
90
						$mail = ($row['mail'] != '') ? $row['mail'] : '-';
90
						$mail = ($row['mail'] != '') ? $row['mail'] : '-';
91
						$mobile = ($row['mobile'] != '') ? $row['mobile'] : '-';
91
						$mobile = ($row['mobile'] != '') ? $row['mobile'] : '-';
92
					}
92
					}
93
				}
93
				}
94
				else
94
				else
95
					echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
95
					echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
96
			}
96
			}
97
		}
97
		}
98
		else
98
		else
99
			echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
99
			echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
100
		if (isset($tmp)){
100
		if (isset($tmp)){
101
			foreach(array_keys($tmp) as $val){
101
			foreach(array_keys($tmp) as $val){
-
 
102
				unset($key);
102
				if ($val == '')
103
				if ($val == '')
103
					continue;
104
					continue;
104
				if(isset($rev_attrmap["$val"])) {
105
				if(isset($rev_attrmap["$val"])) {
105
					$key = $rev_attrmap["$val"];
106
					$key = $rev_attrmap["$val"];
106
				}
107
				}
107
				if ($key == ''){
108
				if ($key == ''){
108
					$key = $val;
109
					$key = $val;
109
					$attrmap["$key"] = $val;
110
					$attrmap["$key"] = $val;
110
					$attr_type["$key"] = 'replyItem';
111
					$attr_type["$key"] = 'replyItem';
111
					$rev_attrmap["$val"] = $key;
112
					$rev_attrmap["$val"] = $key;
112
				}
113
				}
113
				$item_vals["$key"] = $tmp[$val];
114
				$item_vals["$key"] = $tmp[$val];
114
				if(isset($tmp["$attr"]['count']) && isset($item_vals["$key"]['count'])) $item_vals["$key"]['count'] = $tmp[$val]['count'];
115
				if(isset($tmp["$attr"]['count']) && isset($item_vals["$key"]['count'])) $item_vals["$key"]['count'] = $tmp[$val]['count'];
115
				if ($use_op)
116
				if ($use_op)
116
					$item_vals["$key"]['operator'] = $tmp[$val]['operator'];
117
					$item_vals["$key"]['operator'] = $tmp[$val]['operator'];
117
			}
118
			}
118
		}
119
		}
119
 
120
 
120
	}
121
	}
121
	else
122
	else
122
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
123
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
123
}
124
}
124
else
125
else
125
	echo "<b>Could not connect to SQL database</b><br>\n";
126
	echo "<b>Could not connect to SQL database</b><br>\n";
126
 
127
 
127
?>
128
?>
128
 
129