* Add support for groups in SQL. Added several new files and modified a few more.
authorkkalev <kkalev>
Sat, 10 Aug 2002 16:49:21 +0000 (16:49 +0000)
committerkkalev <kkalev>
Sat, 10 Aug 2002 16:49:21 +0000 (16:49 +0000)
* Default values in SQL are now extracted from the group membership. Added a lib/sql/defaults.php3 file.
  As a result the default operator is not '=' anymore but whatever we find in the group check and reply tables.
* In lib/sql/user_info.php3 set user_exists in more than one places.
* Add support for the '=*' and '!*' operators
* Added a HELP_WANTED file describing what are the major things missing which people could contribute.
* Updated TODO

22 files changed:
dialup_admin/AUTHORS
dialup_admin/Changelog
dialup_admin/HELP_WANTED [new file with mode: 0644]
dialup_admin/TODO
dialup_admin/conf/user_edit.attrs
dialup_admin/htdocs/buttons.html
dialup_admin/htdocs/group_admin.php3 [new file with mode: 0644]
dialup_admin/htdocs/group_new.php3 [new file with mode: 0644]
dialup_admin/htdocs/help/idle_timeout_help.html [new file with mode: 0644]
dialup_admin/htdocs/help/session_timeout_help.html [new file with mode: 0644]
dialup_admin/htdocs/user_delete.php3
dialup_admin/htdocs/user_edit.php3
dialup_admin/html/group_toolbar.html.php3 [new file with mode: 0644]
dialup_admin/lib/operators.php3
dialup_admin/lib/sql/change_attrs.php3
dialup_admin/lib/sql/create_group.php3 [new file with mode: 0644]
dialup_admin/lib/sql/defaults.php3 [new file with mode: 0644]
dialup_admin/lib/sql/delete_group.php3 [new file with mode: 0644]
dialup_admin/lib/sql/delete_user.php3
dialup_admin/lib/sql/group_admin.php3 [new file with mode: 0644]
dialup_admin/lib/sql/group_info.php3 [new file with mode: 0644]
dialup_admin/lib/sql/user_info.php3

index 74a6616..439babe 100644 (file)
@@ -15,4 +15,4 @@ A number of bug reports and a lot of crash testing
 
 Alex Savguira: alexs@ravdata.com
 Ido Shavit
-Patches for auto generate password and sql group support
+Patches for auto generate password
index 89f3327..698bca1 100644 (file)
@@ -1,3 +1,11 @@
+Ver 1.50:
+* Add support for groups in SQL. Added several new files and modified a few more.
+* Default values in SQL are now extracted from the group membership. Added a lib/sql/defaults.php3 file.
+  As a result the default operator is not '=' anymore but whatever we find in the group check and reply tables.
+* In lib/sql/user_info.php3 set user_exists in more than one places.
+* Add support for the '=*' and '!*' operators
+* Added a HELP_WANTED file describing what are the major things missing which people could contribute.
+* Updated TODO
 Ver 1.30:
 * Add limit of results returned in accounting.php3
 * Fix a bug in time2strclock() in lib/functions.php3. Seconds ammount more than 9 would not show.
diff --git a/dialup_admin/HELP_WANTED b/dialup_admin/HELP_WANTED
new file mode 100644 (file)
index 0000000..c5c7b81
--- /dev/null
@@ -0,0 +1,7 @@
+What you can contribute:
+
+o Billing and statistics pages. Fancy bars and diagrams are needed for dialup_admin to be complete.
+
+o Documentation.
+
+o Attribute help pages like those that already exist.
index 90e6b00..c6736ce 100644 (file)
@@ -10,3 +10,7 @@
   sql db if it cannot get user info from the nas server
 * Check out dbx library. It seems very promising for database independent code.
   We 'll see where it goes.
+* Add billing and statistics pages. Billing is a must. The page should also create
+  reports which could be printed or sent by email to the users containing their billing
+  information. We also need more statistics pages with fancy bars and diagrams. Ideas
+  are welcome.
index f83d651..3d723eb 100644 (file)
@@ -15,8 +15,8 @@ Framed-Compression            <a href="help/framed_compression_help.html" target=fc_help o
 #Callback-Id
 #Framed-IPX-Network
 #Class
-Session-Timeout                        Session Timeout
-Idle-Timeout                   Idle Timeout
+Session-Timeout                        <a href="help/session_timeout_help.html" target=st_help onclick=window.open("help/session_timeout_help.html","st_help","width=600,height=170,toolbar=no,scrollbars=no,resizable=yes") title="Session Timeout Help Page"><font color="blue">Session Timeout</font></a>
+Idle-Timeout                   <a href="help/idle_timeout_help.html" target=it_help onclick=window.open("help/idle_timeout_help.html","it_help","width=600,height=170,toolbar=no,scrollbars=no,resizable=yes") title="Idle Timeout Help Page"><font color="blue">Idle Timeout</font></a>
 #Termination-Action
 #Login-LAT-Service
 #Login-LAT-Node
index a6555f5..f75ef49 100644 (file)
@@ -53,6 +53,17 @@ function myout(a) {
        <a id="a9" href="user_new.php3" target="content" title="Create New User">New User</a>
        </td></tr>
        <tr align=left><td><img src="images/black.gif" vspace=2 hspace=0 width=80 height=1></td></tr>
+</form>
+<form action="group_admin.php3" method=get target="content">
+       <tr align=left><td id="menu11" onmouseover='myin("11");' onmouseout='myout("11");'>
+       <a id="a11" href="group_admin.php3" target="content" title="Group Administration">Edit Group</a>
+       <img align=top src="images/black.gif" vspace=7 hspace=0 width=1 height=1><br>
+       <input type="text" size=11 name="login" target="content">
+       </td></tr>
+       <tr align=left><td id="menu12" onmouseover='myin("12");' onmouseout='myout("12");'>
+       <a id="a12" href="group_new.php3" target="content" title="Create New Group">New Group</a>
+       </td></tr>
+       <tr align=left><td><img src="images/black.gif" vspace=2 hspace=0 width=80 height=1></td></tr>
        <tr align=left><td id="menu10" onmouseover='myin("10");' onmouseout='myout("10");'>
        <a id="a10" href="user_test.php3?login=da_server_test&test_user=1" target="content" title="Check Server Response">Check Server</a>
        </td></tr>
diff --git a/dialup_admin/htdocs/group_admin.php3 b/dialup_admin/htdocs/group_admin.php3
new file mode 100644 (file)
index 0000000..83b3b8c
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+require('../conf/config.php3');
+if ($config[general_lib_type] != 'sql'){
+       echo <<<EOM
+<title>Group Administration Page</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<b>This page is only available if you are using sql as general library type</b>
+</body>
+</html>
+EOM;
+       exit();
+}
+
+if (is_file("../lib/$config[general_lib_type]/group_info.php3")){
+       include("../lib/$config[general_lib_type]/group_info.php3");
+       if ($group_exists == 'no'){
+               echo <<<EOM
+<title>Group Administration Page</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<form action="group_admin.php3" method=get>
+<b>Group Name&nbsp;&nbsp;</b>
+<input type="text" size=10 name="login" value="$login">
+<b>&nbsp;&nbsp;does not exist</b><br>
+<input type=submit class=button value="Show Group">
+</body>
+</html>
+EOM;
+                exit();
+        }
+}
+?>
+
+<html>
+<head>
+<title>Group Administration Page</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<table border=0 width=550 cellpadding=0 cellspacing=0>
+<tr valign=top>
+<td align=center><img src="images/title2.gif"></td>
+</tr>
+</table>
+<table border=0 width=400 cellpadding=0 cellspacing=2>
+
+<?php
+include("../html/group_toolbar.html.php3");
+?>
+
+</table>
+<br>
+<table border=0 width=540 cellpadding=1 cellspacing=1>
+<tr valign=top>
+<td width=340></td>
+<td bgcolor="black" width=200>
+       <table border=0 width=100% cellpadding=2 cellspacing=0>
+       <tr bgcolor="#907030" align=right valign=top><th>
+       <font color="white">Group <?php echo $login ?> Administration</font>&nbsp;
+       </th></tr>
+       </table>
+</td></tr>
+<tr bgcolor="black" valign=top><td colspan=2>
+       <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
+       <tr><td>
+
+<?php
+if ($do_changes == 1){
+       if (is_file("../lib/$config[general_lib_type]/group_admin.php3"))
+               include("../lib/$config[general_lib_type]/group_admin.php3");
+       if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
+               include("../lib/$config[general_lib_type]/group_info.php3");
+}
+?>
+       
+   
+   <form method=post>
+      <input type=hidden name=login value=<?php echo $login ?>>
+      <input type=hidden name=do_changes value=0>
+       <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
+<tr>
+<td align=right bgcolor="#d0ddb0">
+Group Members (Check to Delete)
+</td>
+<td>
+<select name=del_members[] multiple size=5> 
+<?php
+foreach ($group_members as $member){
+       echo "<option value=\"$member\">$member\n";
+}
+?>
+</select>
+</td>
+</tr>
+<tr>
+<td align=right bgcolor="#d0ddb0">
+New Group Member
+</td>
+<td>
+<input type=text name=new_member value="" size=25>
+</td>
+</tr>
+       </table>
+<br>
+<input type=submit class=button value="Commit Changes" OnClick="this.form.do_changes.value=1">
+</form>
+</td></tr>
+</table>
+</tr>
+</table>
+</body>
+</html>
diff --git a/dialup_admin/htdocs/group_new.php3 b/dialup_admin/htdocs/group_new.php3
new file mode 100644 (file)
index 0000000..0af6e32
--- /dev/null
@@ -0,0 +1,139 @@
+<?php
+if ($show == 1){
+       header("Location: group_admin.php3?login=$login");
+       exit;
+}
+require('../conf/config.php3');
+require('../lib/attrshow.php3');
+require('../lib/defaults.php3');
+
+if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
+       $colspan=2;
+       $show_ops=1;
+}else{
+       $show_ops = 0;
+       $colspan=1;
+}
+
+?>
+
+<html>
+<head>
+<title>New group creation page</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<table border=0 width=550 cellpadding=0 cellspacing=0>
+<tr valign=top>
+<td align=center><img src="images/title2.gif"></td>
+</tr>
+</table>
+
+<br>
+<table border=0 width=540 cellpadding=1 cellspacing=1>
+<tr valign=top>
+<td width=340></td>
+<td bgcolor="black" width=200>
+       <table border=0 width=100% cellpadding=2 cellspacing=0>
+       <tr bgcolor="#907030" align=right valign=top><th>
+       <font color="white">Preferences for new group</font>&nbsp;
+       </th></tr>
+       </table>
+</td></tr>
+<tr bgcolor="black" valign=top><td colspan=2>
+       <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
+       <tr><td>
+   
+<?php
+if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
+       include("../lib/$config[general_lib_type]/group_info.php3");
+if ($create == 1){
+       if ($group_exists != "no"){
+               echo <<<EOM
+<b>The group <i>$login</i> already exists in the group database</b>
+EOM;
+       }
+       else{
+               if (is_file("../lib/$config[general_lib_type]/create_group.php3"))
+                       include("../lib/$config[general_lib_type]/create_group.php3");
+               if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
+                       include("../lib/$config[general_lib_type]/group_info.php3");
+       }
+}
+?>
+   <form method=post>
+      <input type=hidden name=create value="0">
+      <input type=hidden name=show value="0">
+       <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
+<?php
+       echo <<<EOM
+       <tr>
+               <td align=right colspan=$colspan bgcolor="#d0ddb0">
+               Group name
+               </td><td>
+               <input type=text name="login" value="$login" size=35>
+               </td>
+       </tr>
+       <tr>
+               <td align=right colspan=$colspan bgcolor="#d0ddb0">
+               First member
+               </td><td>
+               <input type=text name="member" value="" size=35>
+               </td>
+       </tr>
+               
+EOM;
+       foreach($show_attrs as $key => $desc){
+               $name = $attrmap["$key"];
+               if ($name == 'none')
+                       continue;
+               $oper_name = $name . '_op';
+               $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"];
+               print <<<EOM
+<tr>
+<td align=right bgcolor="#d0ddb0">
+$desc
+</td>
+EOM;
+
+               if ($show_ops)
+                       print <<<EOM
+<td>
+<select name=$oper_name>
+<option selected value="=">=
+<option value=":=">:=
+<option value="+=">+=
+<option value="==">==
+<option value="!=">!=
+<option value=">">&gt;
+<option value=">=">&gt;=
+<option value="<">&lt;
+<option value="<=">&lt;=
+<option value="=~">=~
+<option value="!~">!~
+
+</select>
+</td>
+EOM;
+
+               print <<<EOM
+<td>
+<input type=text name="$name" value="$val" size=35>
+</td>
+</tr>
+EOM;
+       }
+?>
+       </table>
+<br>
+<input type=submit class=button value="Create" OnClick="this.form.create.value=1">
+<br><br>
+<input type=submit class=button value="Show Group" OnClick="this.form.show.value=1">
+</form>
+       </td></tr>
+</table>
+</tr>
+</table>
+</body>
+</html>
diff --git a/dialup_admin/htdocs/help/idle_timeout_help.html b/dialup_admin/htdocs/help/idle_timeout_help.html
new file mode 100644 (file)
index 0000000..eafc611
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+<head>
+<title>Idle Timeout Help Page</title>
+<link rel="stylesheet" href="../style.css">
+</head>
+<body bgcolor="#80a040" background="../images/greenlines1.gif" link="black" alink="black">
+<center>
+<table border=0 width=540 cellpadding=1 cellspacing=1>
+<tr valign=top>
+<td width=340></td>
+<td bgcolor="black" width=400>
+       <table border=0 width=100% cellpadding=2 cellspacing=0>
+       <tr bgcolor="#907030" align=right valign=top><th><font color="white">Idle Timeout Help Page</font>&nbsp;</th></tr>
+       </table>
+</td></tr>
+<tr bgcolor="black" valign=top><td colspan=2>
+       <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
+       <tr><td>
+<br>
+<center>
+<pre>
+  This Attribute sets the maximum number of consecutive seconds of
+  idle connection allowed to the user before termination of the
+  session or prompt.
+</pre>
+</td></tr>
+<tr><td align=center>
+<a href="javascript:window.close();"><b>Close Window</b></a>
+</td></tr>
+</center>
+</table>
+</tr>
+</table>
+</body>
+</html>
diff --git a/dialup_admin/htdocs/help/session_timeout_help.html b/dialup_admin/htdocs/help/session_timeout_help.html
new file mode 100644 (file)
index 0000000..b246443
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>Session Timeout Help Page</title>
+<link rel="stylesheet" href="../style.css">
+</head>
+<body bgcolor="#80a040" background="../images/greenlines1.gif" link="black" alink="black">
+<center>
+<table border=0 width=540 cellpadding=1 cellspacing=1>
+<tr valign=top>
+<td width=340></td>
+<td bgcolor="black" width=400>
+       <table border=0 width=100% cellpadding=2 cellspacing=0>
+       <tr bgcolor="#907030" align=right valign=top><th><font color="white">Session Timeout Help Page</font>&nbsp;</th></tr>
+       </table>
+</td></tr>
+<tr bgcolor="black" valign=top><td colspan=2>
+       <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
+       <tr><td>
+<br>
+<center>
+<pre>
+  This Attribute sets the maximum number of seconds of service to be
+  provided to the user before termination of the session or prompt.
+</pre>
+</td></tr>
+<tr><td align=center>
+<a href="javascript:window.close();"><b>Close Window</b></a>
+</td></tr>
+</center>
+</table>
+</tr>
+</table>
+</body>
+</html>
index b41bf27..f0f2bc0 100644 (file)
@@ -1,12 +1,26 @@
 <?php
 require('../conf/config.php3');
-if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
-       include("../lib/$config[general_lib_type]/user_info.php3");
+if ($type != 'group')
+       if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
+               include("../lib/$config[general_lib_type]/user_info.php3");
+else
+       if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
+               include("../lib/$config[general_lib_type]/group_info.php3");
+
+$whatis = ($user_type == 'group') ? 'group' : 'user';
+$whatisL = ($user_type == 'group') ? 'Group' : 'User';
 
 echo <<<EOM
 <html>
 <head>
-<title>delete user $login ($cn)</title>
+EOM;
+
+if ($user_type != 'group')
+       echo "<title>delete user $login ($cn)</title>\n";
+else
+       echo "<title>delete group $login</title>\n";
+
+echo <<<EOM
 <link rel="stylesheet" href="style.css">
 </head>
 <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
@@ -20,7 +34,10 @@ echo <<<EOM
 <table border=0 width=400 cellpadding=0 cellspacing=2>
 EOM;
 
-include("../html/user_toolbar.html.php3");
+if ($user_type != 'group')
+       include("../html/user_toolbar.html.php3");
+else
+       include("../html/group_toolbar.html.php3");
 
 print <<<EOM
 </table>
@@ -32,7 +49,7 @@ print <<<EOM
 <td bgcolor="black" width=200>
        <table border=0 width=100% cellpadding=2 cellspacing=0>
        <tr bgcolor="#907030" align=right valign=top><th>
-       <font color="white">User $login Deletion</font>&nbsp;
+       <font color="white">$whatisL $login Deletion</font>&nbsp;
        </th></tr>
        </table>
 </td></tr>
@@ -42,8 +59,14 @@ print <<<EOM
 EOM;
    
 if ($delete_user == 1){
-       if (is_file("../lib/$config[general_lib_type]/delete_user.php3"))
-               include("../lib/$config[general_lib_type]/delete_user.php3");
+       if ($user_type != 'group'){
+               if (is_file("../lib/$config[general_lib_type]/delete_user.php3"))
+                       include("../lib/$config[general_lib_type]/delete_user.php3");
+       }
+       else{
+               if (is_file("../lib/$config[general_lib_type]/delete_group.php3"))
+                       include("../lib/$config[general_lib_type]/delete_group.php3");
+       }
        echo <<<EOM
 </td></tr>
 </table>
@@ -61,7 +84,7 @@ EOM;
        <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
 <tr>
 <td align=center>
-Are you sure you want to delete user <?php echo $login; ?> ?
+Are you sure you want to delete <?php echo "$whatis $login"; ?> ?
 </td>
 </tr>
        </table>
index b7f5c3c..3e2c30c 100644 (file)
@@ -1,9 +1,19 @@
 <?php
+if ($edit_group == 1){
+       header("Location: group_admin.php3?login=$group_to_edit");
+       exit;
+}
 require('../conf/config.php3');
 require('../lib/attrshow.php3');
 require('../lib/defaults.php3');
-if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
-       include("../lib/$config[general_lib_type]/user_info.php3");
+if ($user_type != 'group'){
+       if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
+               include("../lib/$config[general_lib_type]/user_info.php3");
+}
+else{
+       if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
+               include("../lib/$config[general_lib_type]/group_info.php3");
+}
 if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
        $colspan=2;
        $show_ops = 1;
@@ -18,13 +28,21 @@ else{
 echo <<<EOM
 <html>
 <head>
-<title>subscription configuration for $login ($cn)</title>
+EOM;
+
+if ($user_type != 'group')
+       echo " <title>subscription configuration for $login ($cn)</title>\n";
+else
+       echo " <title>subscription configuration for $login</title>\n";
+
+echo <<<EOM
 <link rel="stylesheet" href="style.css">
 </head>
 <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
 EOM;
 
-include("password_generator.jsc");
+if ($user_type != 'group')
+       include("password_generator.jsc");
 
 echo <<<EOM
 <center>
@@ -37,7 +55,10 @@ echo <<<EOM
 <table border=0 width=400 cellpadding=0 cellspacing=2>
 EOM;
 
-include("../html/user_toolbar.html.php3");
+if ($user_type != 'group')
+       include("../html/user_toolbar.html.php3");
+else
+       include("../html/group_toolbar.html.php3");     
 
 print <<<EOM
 </table>
@@ -61,10 +82,16 @@ EOM;
 if ($change == 1){
        if (is_file("../lib/$config[general_lib_type]/change_attrs.php3"))
                include("../lib/$config[general_lib_type]/change_attrs.php3");
-       if ($passwd != '' && is_file("../lib/$config[general_lib_type]/change_passwd.php3"))
-               include("../lib/$config[general_lib_type]/change_passwd.php3");
-       if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
-               include("../lib/$config[general_lib_type]/user_info.php3");
+       if ($user_type != 'group'){
+               if ($passwd != '' && is_file("../lib/$config[general_lib_type]/change_passwd.php3"))
+                       include("../lib/$config[general_lib_type]/change_passwd.php3");
+               if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
+                       include("../lib/$config[general_lib_type]/user_info.php3");
+       }
+       else{
+               if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
+                       include("../lib/$config[general_lib_type]/group_info.php3");
+       }
 }
 else if ($badusers == 1){
        if (is_file("../lib/add_badusers.php3"))
@@ -74,19 +101,24 @@ else if ($badusers == 1){
 ?>
    <form method=post>
       <input type=hidden name=login value=<?php print $login ?>>
+      <input type=hidden name=user_type value=<?php print $user_type ?>>
       <input type=hidden name=change value="0">
       <input type=hidden name=add value="0">
       <input type=hidden name=badusers value="0">
        <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
+<?php
+if ($user_type != 'group'){
+       echo <<<EOM
 <tr>
-<td align=right colspan=<?php print $colspan ?> bgcolor="#d0ddb0">
+<td align=right colspan=$colspan bgcolor="#d0ddb0">
 User Password (changes only)
 </td>
 <td>
 <input type=password name=passwd value="" size=40>
 </td>
 </tr>
-<?php
+EOM;
+}
        foreach($show_attrs as $key => $desc){
                $name = $attrmap["$key"];
                if ($name == 'none')
@@ -102,7 +134,7 @@ User Password (changes only)
                }
                else{
                        $vals[] = $default_vals["$key"];
-                       $ops[] = '=';
+                       $ops[] = ($default_vals["$key"][operator] != '') ? $default_vals["$key"][operator] : '=';
                }
                if ($add && $name == $add_attr){
                        array_push($vals, $default_vals["$key"]);
@@ -142,6 +174,8 @@ EOM;
 <option $selected[$op_le] value="<=">&lt;=
 <option $selected[$op_regeq] value="=~">=~
 <option $selected[$op_regne] value="!~">!~
+<option $selected[$op_exst] value="=*">=*
+<option $selected[$op_nexst] value="!*">!*
 </select>
 </td>
 EOM;
@@ -172,13 +206,43 @@ EOM;
 </select>
 </td>
 </tr>
+
+<?php
+if (isset($member_groups)){
+       echo <<<EOM
+<tr>
+<input type=hidden name=edit_group value=0>
+<td align=right colspan=$colspan bgcolor="#d0ddb0">
+Member of
+</td>
+<td>
+<select name="group_to_edit">
+EOM;
+       foreach ($member_groups as $group){
+               echo "<option value=\"$group\">$group\n";
+       }
+       echo <<<EOM
+</select>
+&nbsp;&nbsp;&nbsp;
+<input type=submit class=button value="Edit Group" OnClick="this.form.edit_group.value=1">
+</td>
+</tr>
+EOM;
+}
+?>
        </table>
 <br>
 <input type=submit class=button value=Change OnClick="this.form.change.value=1">
+<?php
+if ($user_type != 'group'){
+       echo <<<EOM
 <br><br>
 <input type=submit class=button value="Add to Badusers" OnClick="this.form.badusers.value=1">
 <br><br>
 <input type="button" class=button value="Auto/Password" OnClick="generatepassword(this.form.passwd,8);">
+EOM;
+}
+?>
 </form>
        </td></tr>
 </table>
diff --git a/dialup_admin/html/group_toolbar.html.php3 b/dialup_admin/html/group_toolbar.html.php3
new file mode 100644 (file)
index 0000000..0763565
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+print <<<EOM
+<tr valign=top>
+<td align=center bgcolor="black" width=100>
+<a href="group_admin.php3?login=$login" title="Administer Group"><font color="white"><b>ADMIN</b></font></a></td>
+<td align=center bgcolor="black" width=100>
+<a href="user_edit.php3?login=$login&user_type=group" title="Edit Group Dialup Settings"><font color="white"><b>EDIT</b></font></a></td>
+<td align=center bgcolor="black" width=100>
+<a href="user_delete.php3?login=$login&user_type=group" title="Delete Group"><font color="white"><b>DELETE</b></font></a></td>
+</tr>
+EOM;
+?>
index b4841af..95525cb 100644 (file)
@@ -10,6 +10,8 @@ $op_lt = '<';
 $op_le = '<=';
 $op_regeq = '=~';
 $op_regne = '!~';
+$op_exst = '=*';
+$op_nexst = '!*';
 
 // Check the operator if it is allowed for this type of
 // attribute (check or reply).
@@ -32,6 +34,8 @@ function check_operator($op,$type)
                case '<=':
                case '=~':
                case '!~':
+               case '=*':
+               case '!*':
                        return ($type == 1) ? 0 : -1;
        }
 }
index bc09b11..fce0ba4 100644 (file)
@@ -27,12 +27,13 @@ if ($link){
                        $name = $attrmap["$key"] . $i;
 
                        $sql_attr=$attrmap["$key"];
+                       $query_key = ($user_type == 'group') ? 'GroupName' : 'UserName';
                        if ($attr_type["$key"] == 'checkItem'){
-                               $table = $config[sql_check_table];
+                               $table = ($user_type == 'group') ? $config[sql_groupcheck_table] : $config[sql_check_table];
                                $type = 1;
                        }
                        else if ($attr_type["$key"] == 'replyItem'){
-                               $table = $config[sql_reply_table];
+                               $table = ($user_type == 'group') ? $config[sql_groupreply_table] : $config[sql_reply_table];
                                $type = 2;
                        }
                        if ($use_ops){
@@ -50,7 +51,7 @@ if ($link){
                        if ($use_ops && isset($item_vals["$key"][operator][$j]) &&
                                $op_val != $item_vals["$key"][operator][$j] ){
                                $res = @da_sql_query($link,$config,
-                               "UPDATE $table SET op = '$op_val' WHERE UserName = '$login'
+                               "UPDATE $table SET op = '$op_val' WHERE $query_key = '$login'
                                AND Attribute = '$sql_attr' AND Value = '$val';");
                                if (!$res || !@da_sql_affected_rows($link,$res,$config))
                                        echo "<b>Operator change failed for attribute $key</b><br>\n";
@@ -62,7 +63,7 @@ if ($link){
        //      if value is null and corresponding value exists then delete
                        else if (($val == $default_vals["$key"] || $val == '') && isset($item_vals["$key"][$j])){
                                $res = @da_sql_query($link,$config,
-                               "DELETE FROM $table WHERE UserName = '$login' AND Attribute = '$sql_attr';");
+                               "DELETE FROM $table WHERE $query_key = '$login' AND Attribute = '$sql_attr';");
                                if (!$res || !@da_sql_affected_rows($link,$res,$config))
                                        echo "<b>Delete failed for attribute $key</b><br>\n";
                        }
@@ -74,12 +75,12 @@ if ($link){
                                if (isset($item_vals["$key"][$j])){
                                        $old_val = $item_vals["$key"][$j];
                                        $res = @da_sql_query($link,$config,
-                                       "UPDATE $table SET Value = '$val' WHERE UserName = '$login' AND
+                                       "UPDATE $table SET Value = '$val' WHERE $query_key = '$login' AND
                                        Attribute = '$sql_attr' AND Value = '$old_val';");
                                }
                                else
                                        $res = @da_sql_query($link,$config,
-                                       "INSERT INTO $table (UserName,Attribute,Value $text2)
+                                       "INSERT INTO $table ($query_key,Attribute,Value $text2)
                                        VALUES ('$login','$sql_attr','$val' $op_val2);");
                                if (!$res || !@da_sql_affected_rows($link,$res,$config))
                                        echo "<b>Change failed for attribute $key</b><br>\n";   
diff --git a/dialup_admin/lib/sql/create_group.php3 b/dialup_admin/lib/sql/create_group.php3
new file mode 100644 (file)
index 0000000..1f4e70c
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
+       include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
+else{
+       echo "<b>Could not include SQL library</b><br>\n";
+       exit();
+}
+if ($config[sql_use_operators] == 'true'){
+       include("../lib/operators.php3");
+       $text = ',op';
+       $passwd_op = ",':='";
+}
+$da_abort=0;
+$link = @da_sql_pconnect($config);
+if ($link){
+       $res = @da_sql_query($link,$config,
+       "INSERT INTO $config[sql_usergroup_table] (UserName,GroupName)
+       VALUES ('$member','$login');");
+       if (!$res || !@da_sql_affected_rows($link,$res,$config)){
+               echo "<b>Unable to add group $login. SQL error</b><br>\n";
+               $da_abort=1;
+       }
+       if (!$da_abort){
+               foreach($show_attrs as $key => $attr){
+                       if ($attrmap["$key"] == 'none')
+                               continue;
+                       if ($attr_type[$key] == 'checkItem'){
+                               $table = "$config[sql_groupcheck_table]";
+                               $type = 1;
+                       }
+                       else if ($attr_type[$key] == 'replyItem'){
+                               $table = "$config[sql_groupreply_table]";
+                               $type = 2;
+                       }
+                       $val = $$attrmap["$key"];
+                       $op_name = $attrmap["$key"] . '_op';
+                       $op_val = $$op_name;
+                       if ($op_val != ''){
+                               if (check_operator($op_val,$type) == -1){
+                                       echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
+                                       coninue;
+                               }
+                               $op_val = ",'$op_val'";
+                       }
+                       if ($val == '' || $val == $default_vals["$key"])
+                               continue;
+                       $res = @da_sql_query($link,$config,
+                       "INSERT INTO $table (Attribute,Value,GroupName $text)
+                       VALUES ('$attrmap[$key]','$val','$login' $op_val);");
+                       if (!$res || !@da_sql_affected_rows($link,$res,$config))
+                               echo "<b>Query failed for attribute $key</b><br>\n";
+               }
+       }
+       echo "<b>Group created successfully</b><br>\n";
+}
+else
+       echo "<b>Could not connect to database</b><br>\n";
+?>
diff --git a/dialup_admin/lib/sql/defaults.php3 b/dialup_admin/lib/sql/defaults.php3
new file mode 100644 (file)
index 0000000..06bec34
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+require('../lib/sql/attrmap.php3');
+if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
+       include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
+else{
+       echo "<b>Could not include SQL library</b><br>\n";
+       exit();
+}
+if ($config[sql_use_operators] == 'true'){
+       $op = ',op';
+       $use_op = 1;
+}else{
+       $op = "";
+       $use_op = 0;
+}
+unset($item_vals);
+unset($tmp);
+$link = @da_sql_pconnect($config);
+if ($link){
+       $res = @da_sql_query($link,$config,
+       "SELECT GroupName FROM $config[sql_usergroup_table] WHERE UserName = '$login';");
+       if ($res){
+               while(($row = @da_sql_fetch_array($res,$config)))
+                       $member_groups[] = $row[GroupName];
+       }
+       if (isset($member_groups)){
+               foreach ($member_groups as $group){
+                       $res = @da_sql_query($link,$config,
+                       "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table] WHERE GroupName = '$group';");
+                       if ($res){
+                               while(($row = @da_sql_fetch_array($res,$config))){
+                                       $attr = $row[Attribute];
+                                       $val = $row[Value];
+                                       if ($use_op){
+                                               $oper = $row[op];
+                                               $tmp["$attr"][operator][]="$oper";
+                                       }
+                                       $tmp["$attr"][]="$val";
+                                       $tmp["$attr"][count]++;
+                               }
+                               $res = @da_sql_query($link,$config,
+                               "SELECT Attribute,Value $op FROM $config[sql_groupreply_table] WHERE GroupName = '$group';");
+                               if ($res){
+                                       while(($row = @da_sql_fetch_array($res,$config))){
+                                               $attr = $row[Attribute];
+                                               $val = $row[Value];
+                                               if ($use_op){
+                                                       $oper = $row[op];
+                                                       $tmp["$attr"][operator][]="$oper";
+                                               }
+                                               $tmp["$attr"][] = "$val";
+                                               $tmp["$attr"][count]++;
+                                       }
+                               }
+                               else
+                                       echo "<b>Database query failed partially</b><br>\n";
+                       }
+                       else
+                               echo "<b>Database query failed</b><br>\n";      
+                       foreach($attrmap as $key => $val){
+                               if (isset($tmp[$val])){
+                                       if ($tmp[$val][0] != '')
+                                               $default_vals["$key"] = $tmp[$val][0];
+                                       if ($use_op)
+                                               if ($tmp[$val][operator][0] != '')
+                                                       $default_vals["$key"][operator] = $tmp[$val][operator][0];
+                               }
+                       }
+               }
+       }
+}
+else
+       echo "<b>Could not connect to database</b><br>\n";
+?>
diff --git a/dialup_admin/lib/sql/delete_group.php3 b/dialup_admin/lib/sql/delete_group.php3
new file mode 100644 (file)
index 0000000..917a13e
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
+       include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
+else{
+       echo "<b>Could not include SQL library</b><br>\n";
+       exit();
+}
+$link = @da_sql_pconnect($config);
+if ($link){
+       $res = @da_sql_query($link,$config,
+               "DELETE FROM $config[sql_groupreply_table] WHERE GroupName = '$login';");
+       if ($res){
+               $res = @da_sql_query($link,$config,
+                       "DELETE FROM $config[sql_groupcheck_table] WHERE GroupName = '$login';");
+               if ($res){
+                       $res = @da_sql_query($link,$config,
+                               "DELETE FROM $config[sql_usergroup_table] WHERE GroupName = '$login';");
+                               if ($res)
+                                       echo "<b>Group $login deleted successfully</b><br>\n";
+                               else
+                                       echo "<b>Error deleting group $login from usergroup table</b><br>\n";
+               }
+               else
+                       echo "<b>Error deleting group $login from group check table</b><br>\n";
+       }
+       else
+               echo "<b>Error deleting group $login from group reply table</b><br>\n";
+}
+else
+       echo "<b>Could not connect to database</b><br>\n";
+?>
index c8729f9..c068e1f 100644 (file)
@@ -13,6 +13,10 @@ if ($link){
                $res = @da_sql_query($link,$config,
                        "DELETE FROM $config[sql_check_table] WHERE UserName = '$login';");
                if ($res){
+                       $res = @da_sql_query($link,$config,
+                               "DELETE FROM $config[sql_usergroup_table] WHERE UserName = '$login';");
+                       if (!$res)
+                               echo "<b>Error deleting user $login from user group table</b><br>\n";
                        if ($config[sql_use_user_info_table] == 'true'){
                                $res = @da_sql_query($link,$config,
                                "DELETE FROM $config[sql_user_info_table] WHERE UserName = '$login';");
diff --git a/dialup_admin/lib/sql/group_admin.php3 b/dialup_admin/lib/sql/group_admin.php3
new file mode 100644 (file)
index 0000000..90fc433
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
+       include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
+else{
+       echo "<b>Could not include SQL library</b><br>\n";
+       exit();
+}
+$link = @da_sql_pconnect($config);
+if ($link){
+       if (isset($del_members)){
+               foreach ($del_members as $del){
+                       $res = @da_sql_query($link,$config,
+                       "DELETE FROM $config[sql_usergroup_table] WHERE UserName = '$del' AND GroupName = '$login';");
+                       if (!$res)
+                               echo "<b>Could not delete user $del from group. SQL Error</b><br>\n";
+               }
+       }
+       if ($new_member != ''){
+               $res = @da_sql_query($link,$config,
+       "SELECT UserName FROM $config[sql_usergroup_table] WHERE UserName = '$new_member' AND GroupName = '$login';");
+               if ($res){
+                       if (@da_sql_num_rows($res,$config))
+                               echo "<b>User $new_member already is a member of the group</b><br>\n";
+                       else{   
+                               $res = @da_sql_query($link,$config,
+                       "INSERT INTO $config[sql_usergroup_table] (GroupName,UserName) VALUES ('$login','$new_member');");
+                               if (!$res)
+                                       echo "<b>Error while adding user $new_member to group</b><br>\n";
+                       }
+               }
+               else
+                       echo "<b>Could not add new member $new_member. SQL Error</b><br>\n";
+       }
+}
+else
+       echo "<b>Could not connect to database</b><br>\n";
+?>
diff --git a/dialup_admin/lib/sql/group_info.php3 b/dialup_admin/lib/sql/group_info.php3
new file mode 100644 (file)
index 0000000..684e517
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+require('../lib/sql/attrmap.php3');
+if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
+       include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
+else{
+       echo "<b>Could not include SQL library</b><br>\n";
+       exit();
+}
+if ($config[sql_use_operators] == 'true'){
+       $op = ',op';
+       $use_op = 1;
+}else{
+       $op = "";
+       $use_op = 0;
+}
+$group_exists = 'no';
+unset($item_vals);
+unset($tmp);
+unset($group_members);
+$link = @da_sql_pconnect($config);
+if ($link){
+       $res = @da_sql_query($link,$config,
+       "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table] WHERE GroupName = '$login';");
+       if ($res){
+               if (@da_sql_num_rows($res,$config))
+                       $group_exists = 'yes';
+               while(($row = @da_sql_fetch_array($res,$config))){
+                       $attr = $row[Attribute];
+                       $val = $row[Value];
+                       if ($use_op){
+                               $oper = $row[op];
+                               $tmp["$attr"][operator][]="$oper";
+                       }
+                       $tmp["$attr"][]="$val";
+                       $tmp["$attr"][count]++;
+               }
+               $res = @da_sql_query($link,$config,
+               "SELECT Attribute,Value $op FROM $config[sql_groupreply_table] WHERE GroupName = '$login';");
+               if ($res){
+                       if (@da_sql_num_rows($res,$config))
+                               $group_exists = 'yes';
+                       while(($row = @da_sql_fetch_array($res,$config))){
+                               $attr = $row[Attribute];
+                               $val = $row[Value];
+                               if ($use_op){
+                                       $oper = $row[op];
+                                       $tmp["$attr"][operator][]="$oper";
+                               }
+                               $tmp["$attr"][] = "$val";
+                               $tmp["$attr"][count]++;
+                       }
+               }
+               else
+                       echo "<b>Database query failed partially</b><br>\n";
+               $res = @da_sql_query($link,$config,
+               "SELECT UserName FROM $config[sql_usergroup_table] WHERE GroupName = '$login' ORDER BY UserName;");
+               if ($res){
+                       if (@da_sql_num_rows($res,$config))
+                               $group_exists = 'yes';
+                       while(($row = @da_sql_fetch_array($res,$config))){
+                               $member = $row[UserName];
+                               $group_members[] = "$member";
+                       }
+               }       
+               else
+                       echo "<b>Database query failed partially</b><br>\n";
+               foreach($attrmap as $key => $val){
+                       if (isset($tmp[$val])){
+                               $item_vals["$key"] = $tmp[$val];
+                               $item_vals["$key"][count] = $tmp[$val][count];
+                               if ($use_op)
+                                       $item_vals["$key"][operator] = $tmp[$val][operator];
+
+                       }
+               }
+
+       }
+       else
+               echo "<b>Database query failed</b><br>\n";      
+}
+else
+       echo "<b>Could not connect to database</b><br>\n";
+?>
index 0a99248..be6efb8 100644 (file)
@@ -36,6 +36,8 @@ if ($link){
                $res = @da_sql_query($link,$config,
                "SELECT Attribute,Value $op FROM $config[sql_reply_table] WHERE UserName = '$login';");
                if ($res){
+                       if (@da_sql_num_rows($res,$config))
+                               $user_exists = 'yes';
                        while(($row = @da_sql_fetch_array($res,$config))){
                                $attr = $row[Attribute];
                                $val = $row[Value];
@@ -50,6 +52,8 @@ if ($link){
                                $res = @da_sql_query($link,$config,
                                "SELECT * FROM $config[sql_user_info_table] WHERE UserName = '$login';");
                                if ($res){
+                                       if (@da_sql_num_rows($res,$config))
+                                               $user_exists = 'yes';
                                        if (($row = @da_sql_fetch_array($res,$config))){        
                                                $cn = ($row[Name]) ? $row[Name] : '-';
                                                $telephonenumber = ($row[WorkPhone]) ? $row[WorkPhone] : '-';