Subversion Repositories ALCASAR

Rev

Rev 901 | Rev 2333 | 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
}
1805 clement.si 9
if ($config['sql_use_operators'] == 'true'){
509 richard 10
	$op = ',op';
11
	$use_op = 1;
12
}else{
13
	$op = "";
14
	$use_op = 0;
15
}
16
$group_exists = 'no';
1805 clement.si 17
$link = da_sql_pconnect($config);
509 richard 18
if ($link){
1805 clement.si 19
	if (!isset($login) || $login == ''){
509 richard 20
		unset($existing_groups);
21
 
1805 clement.si 22
		$res = da_sql_query($link,$config,
509 richard 23
		"SELECT COUNT(*) as counter,groupname FROM $config[sql_usergroup_table]
24
		GROUP BY groupname;");
25
		if ($res){
1805 clement.si 26
			while(($row = da_sql_fetch_array($res,$config))){
27
				$name = $row['groupname'];
28
				$existing_groups["$name"] = $row['counter'];
509 richard 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
 
1805 clement.si 42
		$res = da_sql_query($link,$config,
509 richard 43
		"SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';");
44
		if ($res){
1805 clement.si 45
			if (da_sql_num_rows($res,$config))
509 richard 46
				$group_exists = 'yes';
1805 clement.si 47
			while(($row = da_sql_fetch_array($res,$config))){
48
				$attr = $row['attribute'];
49
				$val = $row['value'];
50
				if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
683 stephane 51
				/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
901 richard 52
				if($attr == "Max-All-Session") $mas_imp = $val;
683 stephane 53
				if($attr == "Max-Daily-Session") $mds_imp = $val;
54
				if($attr == "Max-Monthly-Session") $mms_imp = $val;
55
				if($attr == "Expiration") $Expiration = $val;
56
				/*Fin Ajout*/
509 richard 57
				if ($use_op){
1805 clement.si 58
					$oper = $row['op'];
59
					$tmp["$attr"]['operator'][]="$oper";
509 richard 60
				}
61
				$tmp["$attr"][]="$val";
1805 clement.si 62
				$tmp["$attr"]['count']++;
509 richard 63
			}
1805 clement.si 64
			$res = da_sql_query($link,$config,
509 richard 65
			"SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';");
66
			if ($res){
1805 clement.si 67
				if (da_sql_num_rows($res,$config))
509 richard 68
					$group_exists = 'yes';
1805 clement.si 69
				while(($row = da_sql_fetch_array($res,$config))){
70
					$attr = $row['attribute'];
71
					$val = $row['value'];
72
					if(!isset($tmp["$attr"]['count'])) $tmp["$attr"]['count'] = 0;
509 richard 73
					/*Ajout en vue de l'impression des données (thank's to Geoffroy MUSITELLI)*/
74
					if($attr == "Session-Timeout") $sto_imp = $val;
75
					/*Fin Ajout*/
76
					if ($use_op){
1805 clement.si 77
						$oper = $row['op'];
78
						$tmp["$attr"]['operator'][]="$oper";
509 richard 79
					}
80
					$tmp["$attr"][] = "$val";
1805 clement.si 81
					$tmp["$attr"]['count']++;
509 richard 82
				}
83
			}
84
			else
85
				echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
1805 clement.si 86
			$res = da_sql_query($link,$config,
509 richard 87
			"SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
88
			if ($res){
1805 clement.si 89
				if (da_sql_num_rows($res,$config))
509 richard 90
					$group_exists = 'yes';
1805 clement.si 91
				while(($row = da_sql_fetch_array($res,$config))){
92
					$member = $row['username'];
509 richard 93
					$group_members[] = "$member";
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;
102
					$key = $rev_attrmap["$val"];
103
					if ($key == ''){
104
						$key = $val;
105
						$attrmap["$key"] = $val;
106
						$attr_type["$key"] = 'replyItem';
107
						$rev_attrmap["$val"] = $key;
108
					}
109
					$item_vals["$key"] = $tmp[$val];
1805 clement.si 110
					$item_vals["$key"]['count'] = $tmp[$val]['count'];
509 richard 111
					if ($use_op)
1805 clement.si 112
						$item_vals["$key"]['operator'] = $tmp[$val]['operator'];
509 richard 113
				}
114
			}
115
		}
116
		else
117
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
118
	}
119
}
120
else
121
	echo "<b>Could not connect to SQL database</b><br>\n";
122
?>