Subversion Repositories ALCASAR

Rev

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