import from HEAD:
[freeradius.git] / dialup_admin / htdocs / show_groups.php3
1 <?php
2 require('../conf/config.php3');
3 ?>
4 <html>
5 <?php
6
7 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
8         include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
9 else{
10         echo <<<EOM
11 <title>User Groups</title>
12 <meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
13 <link rel="stylesheet" href="style.css">
14 </head>
15 <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
16 <center>
17 <b>Could not include SQL library functions. Aborting</b>
18 </body>
19 </html>
20 EOM;
21         exit();
22 }
23 ?>
24 <head>
25 <title>User Groups</title>
26 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
27 <link rel="stylesheet" href="style.css">
28 </head>
29 <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
30 <center>
31 <table border=0 width=550 cellpadding=0 cellspacing=0>
32 <tr valign=top>
33 <td align=center><img src="images/title2.gif"></td>
34 </tr>
35 </table>
36
37 <br><br>
38 <table border=0 width=540 cellpadding=1 cellspacing=1>
39 <tr valign=top>
40 <td width=55%></td>
41 <td bgcolor="black" width=45%>
42         <table border=0 width=100% cellpadding=2 cellspacing=0>
43         <tr bgcolor="#907030" align=right valign=top><th>
44         <font color="white">User Groups</font>&nbsp;
45         </th></tr>
46         </table>
47 </td></tr>
48 <tr bgcolor="black" valign=top><td colspan=2>
49         <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
50         <tr><td>
51 <p>
52         <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
53         <tr bgcolor="#d0ddb0">
54         <th>#</th><th>group</th><th># of members</th>
55         </tr>
56
57 <?php
58 $link = @da_sql_pconnect($config);
59 if ($link){
60         $search = @da_sql_query($link,$config,
61         "SELECT COUNT(*) as counter,groupname,MAX(username) AS usersample FROM $config[sql_usergroup_table] GROUP BY groupname;");
62         if ($search){
63                 if (@da_sql_num_rows($search,$config)){
64                         while( $row = @da_sql_fetch_array($search,$config) ){
65                                 $num++;
66                                 $group = $row[groupname];
67                                 $num_members = $row[counter];
68                                 if ($row[usersample] == "") $num_members--;
69                                 echo <<<EOM
70                 <tr align=center>
71                         <td>$num</td>
72                         <td><a href="group_admin.php3?login=$group" title="Edit group $group">$group</a></td>
73                         <td>$num_members</td>
74                 </tr>
75 EOM;
76                         }
77                 }
78                 else
79                         echo "<b>Could not find any groups</b><br>\n";
80         }
81         else
82                 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
83 }
84 else
85         echo "<b>Could not connect to SQL database</b><br>\n";
86 ?>
87         </table>
88 </table>
89 </tr>
90 </table>
91 </body>
92 </html>