Subversion Repositories ALCASAR

Rev

Rev 654 | Rev 901 | 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];
683 stephane 50
				/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
51
				if($attr == "Max-Daily-Session") $mds_imp = $val;
52
				if($attr == "Max-Monthly-Session") $mms_imp = $val;
53
				if($attr == "Expiration") $Expiration = $val;
54
				/*Fin Ajout*/
509 richard 55
				if ($use_op){
56
					$oper = $row[op];
57
					$tmp["$attr"][operator][]="$oper";
58
				}
59
				$tmp["$attr"][]="$val";
60
				$tmp["$attr"][count]++;
61
			}
62
			$res = @da_sql_query($link,$config,
63
			"SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';");
64
			if ($res){
65
				if (@da_sql_num_rows($res,$config))
66
					$group_exists = 'yes';
67
				while(($row = @da_sql_fetch_array($res,$config))){
68
					$attr = $row[attribute];
69
					$val = $row[value];
70
					/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
71
					if($attr == "Session-Timeout") $sto_imp = $val;
72
					/*Fin Ajout*/
73
					if ($use_op){
74
						$oper = $row[op];
75
						$tmp["$attr"][operator][]="$oper";
76
					}
77
					$tmp["$attr"][] = "$val";
78
					$tmp["$attr"][count]++;
79
				}
80
			}
81
			else
82
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
83
			$res = @da_sql_query($link,$config,
84
			"SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
85
			if ($res){
86
				if (@da_sql_num_rows($res,$config))
87
					$group_exists = 'yes';
88
				while(($row = @da_sql_fetch_array($res,$config))){
89
					$member = $row[username];
90
					$group_members[] = "$member";
91
				}
92
			}
93
			else
94
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
95
			if (isset($tmp)){
96
				foreach(array_keys($tmp) as $val){
97
					if ($val == '')
98
						continue;
99
					$key = $rev_attrmap["$val"];
100
					if ($key == ''){
101
						$key = $val;
102
						$attrmap["$key"] = $val;
103
						$attr_type["$key"] = 'replyItem';
104
						$rev_attrmap["$val"] = $key;
105
					}
106
					$item_vals["$key"] = $tmp[$val];
107
					$item_vals["$key"][count] = $tmp[$val][count];
108
					if ($use_op)
109
						$item_vals["$key"][operator] = $tmp[$val][operator];
110
				}
111
			}
112
		}
113
		else
114
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
115
	}
116
}
117
else
118
	echo "<b>Could not connect to SQL database</b><br>\n";
119
?>