Subversion Repositories ALCASAR

Rev

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

Rev 1831 Rev 1879
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 ='';
-
 
38
 
37
unset($item_vals);
39
unset($item_vals);
38
unset($tmp);
40
unset($tmp);
39
$link = da_sql_pconnect($config);
41
$link = da_sql_pconnect($config);
40
if ($link){
42
if ($link){
41
	$res = da_sql_query($link,$config,
43
	$res = da_sql_query($link,$config,
42
	"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';");
43
	if ($res){
45
	if ($res){
44
		if (da_sql_num_rows($res,$config))
46
		if (da_sql_num_rows($res,$config))
45
			$user_exists = 'yes';
47
			$user_exists = 'yes';
46
		while(($row = da_sql_fetch_array($res,$config))){
48
		while(($row = da_sql_fetch_array($res,$config))){
47
			$attr = $row['attribute'];
49
			$attr = $row['attribute'];
48
			$val = $row['value'];
50
			$val = $row['value'];
49
			if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
51
			if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
50
			if ($attr == $config['sql_password_attribute'] && $val != '')
52
			if ($attr == $config['sql_password_attribute'] && $val != '')
51
				$user_password_exists = 'yes';
53
				$user_password_exists = 'yes';
52
			if ($use_op){
54
			if ($use_op){
53
				$oper = $row['op'];
55
				$oper = $row['op'];
54
				$tmp["$attr"]['operator'][]="$oper";
56
				$tmp["$attr"]['operator'][]="$oper";
55
			}
57
			}
56
			$tmp["$attr"][]="$val";
58
			$tmp["$attr"][]="$val";
57
			$tmp["$attr"]['count']++;
59
			$tmp["$attr"]['count']++;
58
		}
60
		}
59
		$res = da_sql_query($link,$config,
61
		$res = da_sql_query($link,$config,
60
		"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';");
61
		if ($res){
63
		if ($res){
62
			if (da_sql_num_rows($res,$config))
64
			if (da_sql_num_rows($res,$config))
63
				$user_exists = 'yes';
65
				$user_exists = 'yes';
64
			while(($row = da_sql_fetch_array($res,$config))){
66
			while(($row = da_sql_fetch_array($res,$config))){
65
				$attr = $row['attribute'];
67
				$attr = $row['attribute'];
66
				$val = $row['value'];
68
				$val = $row['value'];
67
				if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
69
				if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
68
				if ($use_op){
70
				if ($use_op){
69
					$oper = $row['op'];
71
					$oper = $row['op'];
70
					$tmp["$attr"]['operator'][]="$oper";
72
					$tmp["$attr"]['operator'][]="$oper";
71
				}
73
				}
72
				$tmp["$attr"][] = "$val";
74
				$tmp["$attr"][] = "$val";
73
				$tmp["$attr"]['count']++;
75
				$tmp["$attr"]['count']++;
74
			}
76
			}
75
			if ($config['sql_use_user_info_table'] == 'true'){
77
			if ($config['sql_use_user_info_table'] == 'true'){
76
				$res = da_sql_query($link,$config,
78
				$res = da_sql_query($link,$config,
77
				"SELECT * FROM $config[sql_user_info_table] WHERE username = '$login';");
79
				"SELECT * FROM $config[sql_user_info_table] WHERE username = '$login';");
78
				if ($res){
80
				if ($res){
79
					if (da_sql_num_rows($res,$config)){
81
					if (da_sql_num_rows($res,$config)){
80
						$user_exists = 'yes';
82
						$user_exists = 'yes';
81
						$user_info = 1;
83
						$user_info = 1;
82
					}
84
					}
83
					if (($row = da_sql_fetch_array($res,$config))){
85
					if (($row = da_sql_fetch_array($res,$config))){
84
						$cn = ($row['name'] != '') ? $row['name'] : '-';
86
						$cn = ($row['name'] != '') ? $row['name'] : '-';
85
						$telephonenumber = ($row['workphone'] != '') ? $row['workphone'] : '-';
87
						$telephonenumber = ($row['workphone'] != '') ? $row['workphone'] : '-';
86
						$homephone = ($row['homephone'] != '') ? $row['homephone'] : '-';
88
						$homephone = ($row['homephone'] != '') ? $row['homephone'] : '-';
87
						$ou = ($row['department'] != '') ? $row['department'] : '-';
89
						$ou = ($row['department'] != '') ? $row['department'] : '-';
88
						$mail = ($row['mail'] != '') ? $row['mail'] : '-';
90
						$mail = ($row['mail'] != '') ? $row['mail'] : '-';
89
						$mobile = ($row['mobile'] != '') ? $row['mobile'] : '-';
91
						$mobile = ($row['mobile'] != '') ? $row['mobile'] : '-';
90
					}
92
					}
91
				}
93
				}
92
				else
94
				else
93
					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";
94
			}
96
			}
95
		}
97
		}
96
		else
98
		else
97
			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";
98
		if (isset($tmp)){
100
		if (isset($tmp)){
99
			foreach(array_keys($tmp) as $val){
101
			foreach(array_keys($tmp) as $val){
100
				if ($val == '')
102
				if ($val == '')
101
					continue;
103
					continue;
102
				if(isset($rev_attrmap["$val"])) {
104
				if(isset($rev_attrmap["$val"])) {
103
					$key = $rev_attrmap["$val"];
105
					$key = $rev_attrmap["$val"];
104
				}
106
				}
105
				if ($key == ''){
107
				if ($key == ''){
106
					$key = $val;
108
					$key = $val;
107
					$attrmap["$key"] = $val;
109
					$attrmap["$key"] = $val;
108
					$attr_type["$key"] = 'replyItem';
110
					$attr_type["$key"] = 'replyItem';
109
					$rev_attrmap["$val"] = $key;
111
					$rev_attrmap["$val"] = $key;
110
				}
112
				}
111
				$item_vals["$key"] = $tmp[$val];
113
				$item_vals["$key"] = $tmp[$val];
112
				if(isset($tmp["$attr"]['count']) && isset($item_vals["$key"]['count'])) $item_vals["$key"]['count'] = $tmp[$val]['count'];
114
				if(isset($tmp["$attr"]['count']) && isset($item_vals["$key"]['count'])) $item_vals["$key"]['count'] = $tmp[$val]['count'];
113
				if ($use_op)
115
				if ($use_op)
114
					$item_vals["$key"]['operator'] = $tmp[$val]['operator'];
116
					$item_vals["$key"]['operator'] = $tmp[$val]['operator'];
115
			}
117
			}
116
		}
118
		}
117
 
119
 
118
	}
120
	}
119
	else
121
	else
120
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
122
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
121
}
123
}
122
else
124
else
123
	echo "<b>Could not connect to SQL database</b><br>\n";
125
	echo "<b>Could not connect to SQL database</b><br>\n";
124
 
126
 
125
?>
127
?>
126
 
128