Subversion Repositories ALCASAR

Rev

Rev 2333 | Details | Compare with Previous | Last modification | View Log

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