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