Permit EAP-Message and State from the home server, so that
[freeradius.git] / dialup_admin / lib / sql / group_info.php3
1 <?php
2 require('../lib/sql/attrmap.php3');
3 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
4         include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
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 unset($item_vals);
18 unset($tmp);
19 unset($group_members);
20 $link = @da_sql_pconnect($config);
21 if ($link){
22         $res = @da_sql_query($link,$config,
23         "SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';");
24         if ($res){
25                 if (@da_sql_num_rows($res,$config))
26                         $group_exists = 'yes';
27                 while(($row = @da_sql_fetch_array($res,$config))){
28                         $attr = $row[attribute];
29                         $val = $row[value];
30                         if ($use_op){
31                                 $oper = $row[op];
32                                 $tmp["$attr"][operator][]="$oper";
33                         }
34                         $tmp["$attr"][]="$val";
35                         $tmp["$attr"][count]++;
36                 }
37                 $res = @da_sql_query($link,$config,
38                 "SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';");
39                 if ($res){
40                         if (@da_sql_num_rows($res,$config))
41                                 $group_exists = 'yes';
42                         while(($row = @da_sql_fetch_array($res,$config))){
43                                 $attr = $row[attribute];
44                                 $val = $row[value];
45                                 if ($use_op){
46                                         $oper = $row[op];
47                                         $tmp["$attr"][operator][]="$oper";
48                                 }
49                                 $tmp["$attr"][] = "$val";
50                                 $tmp["$attr"][count]++;
51                         }
52                 }
53                 else
54                         echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
55                 $res = @da_sql_query($link,$config,
56                 "SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
57                 if ($res){
58                         if (@da_sql_num_rows($res,$config))
59                                 $group_exists = 'yes';
60                         while(($row = @da_sql_fetch_array($res,$config))){
61                                 $member = $row[username];
62                                 $group_members[] = "$member";
63                         }
64                 }       
65                 else
66                         echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
67                 if (isset($tmp)){
68                         foreach(array_keys($tmp) as $val){
69                                 if ($val == '')
70                                         continue;
71                                 $key = $rev_attrmap["$val"];
72                                 if ($key == ''){
73                                         $key = $val;
74                                         $attrmap["$key"] = $val;
75                                         $attr_type["$key"] = 'replyItem';
76                                         $rev_attrmap["$val"] = $key;
77                                 }
78                                 $item_vals["$key"] = $tmp[$val];
79                                 $item_vals["$key"][count] = $tmp[$val][count];
80                                 if ($use_op)
81                                         $item_vals["$key"][operator] = $tmp[$val][operator];
82                         }
83                 }
84
85         }
86         else
87                 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
88 }
89 else
90         echo "<b>Could not connect to SQL database</b><br>\n";
91 ?>