Subversion Repositories ALCASAR

Rev

Rev 654 | Go to most recent revision | Details | 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;
69
					/*Fin Ajout*/
70
					if ($use_op){
71
						$oper = $row[op];
72
						$tmp["$attr"][operator][]="$oper";
73
					}
74
					$tmp["$attr"][] = "$val";
75
					$tmp["$attr"][count]++;
76
				}
77
			}
78
			else
79
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
80
			$res = @da_sql_query($link,$config,
81
			"SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
82
			if ($res){
83
				if (@da_sql_num_rows($res,$config))
84
					$group_exists = 'yes';
85
				while(($row = @da_sql_fetch_array($res,$config))){
86
					$member = $row[username];
87
					$group_members[] = "$member";
88
				}
89
			}
90
			else
91
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
92
			if (isset($tmp)){
93
				foreach(array_keys($tmp) as $val){
94
					if ($val == '')
95
						continue;
96
					$key = $rev_attrmap["$val"];
97
					if ($key == ''){
98
						$key = $val;
99
						$attrmap["$key"] = $val;
100
						$attr_type["$key"] = 'replyItem';
101
						$rev_attrmap["$val"] = $key;
102
					}
103
					$item_vals["$key"] = $tmp[$val];
104
					$item_vals["$key"][count] = $tmp[$val][count];
105
					if ($use_op)
106
						$item_vals["$key"][operator] = $tmp[$val][operator];
107
				}
108
			}
109
		}
110
		else
111
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
112
	}
113
}
114
else
115
	echo "<b>Could not connect to SQL database</b><br>\n";
116
?>