Subversion Repositories ALCASAR

Rev

Rev 509 | Rev 683 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
509 richard 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
$group_exists = 'no';
17
$link = @da_sql_pconnect($config);
18
if ($link){
19
	if ($login == ''){
20
		unset($existing_groups);
21
 
22
		$res = @da_sql_query($link,$config,
23
		"SELECT COUNT(*) as counter,groupname FROM $config[sql_usergroup_table]
24
		GROUP BY groupname;");
25
		if ($res){
26
			while(($row = @da_sql_fetch_array($res,$config))){
27
				$name = $row[groupname];
28
				$existing_groups["$name"] = $row[counter];
29
			}
30
			if (isset($existing_groups))
31
				ksort($existing_groups);
32
		}
33
		else
34
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
35
	}
36
	else{
37
		unset($item_vals);
38
		unset($tmp);
39
		unset($group_members);
40
		unset($existing_groups);
41
 
42
		$res = @da_sql_query($link,$config,
43
		"SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';");
44
		if ($res){
45
			if (@da_sql_num_rows($res,$config))
46
				$group_exists = 'yes';
47
			while(($row = @da_sql_fetch_array($res,$config))){
48
				$attr = $row[attribute];
49
				$val = $row[value];
50
				if ($use_op){
51
					$oper = $row[op];
52
					$tmp["$attr"][operator][]="$oper";
53
				}
54
				$tmp["$attr"][]="$val";
55
				$tmp["$attr"][count]++;
56
			}
57
			$res = @da_sql_query($link,$config,
58
			"SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';");
59
			if ($res){
60
				if (@da_sql_num_rows($res,$config))
61
					$group_exists = 'yes';
62
				while(($row = @da_sql_fetch_array($res,$config))){
63
					$attr = $row[attribute];
64
					$val = $row[value];
65
					/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
66
					if($attr == "Session-Timeout") $sto_imp = $val;
67
					if($attr == "Max-Daily-Session") $mds_imp = $val;
68
					if($attr == "Max-Monthly-Session") $mms_imp = $val;
654 richard 69
					if($attr == "Expiration") $Expiration = $val;
509 richard 70
					/*Fin Ajout*/
71
					if ($use_op){
72
						$oper = $row[op];
73
						$tmp["$attr"][operator][]="$oper";
74
					}
75
					$tmp["$attr"][] = "$val";
76
					$tmp["$attr"][count]++;
77
				}
78
			}
79
			else
80
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
81
			$res = @da_sql_query($link,$config,
82
			"SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
83
			if ($res){
84
				if (@da_sql_num_rows($res,$config))
85
					$group_exists = 'yes';
86
				while(($row = @da_sql_fetch_array($res,$config))){
87
					$member = $row[username];
88
					$group_members[] = "$member";
89
				}
90
			}
91
			else
92
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
93
			if (isset($tmp)){
94
				foreach(array_keys($tmp) as $val){
95
					if ($val == '')
96
						continue;
97
					$key = $rev_attrmap["$val"];
98
					if ($key == ''){
99
						$key = $val;
100
						$attrmap["$key"] = $val;
101
						$attr_type["$key"] = 'replyItem';
102
						$rev_attrmap["$val"] = $key;
103
					}
104
					$item_vals["$key"] = $tmp[$val];
105
					$item_vals["$key"][count] = $tmp[$val][count];
106
					if ($use_op)
107
						$item_vals["$key"][operator] = $tmp[$val][operator];
108
				}
109
			}
110
		}
111
		else
112
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
113
	}
114
}
115
else
116
	echo "<b>Could not connect to SQL database</b><br>\n";
117
?>