Subversion Repositories ALCASAR

Rev

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