]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* Fix a small bug in lib/sql/create_user.php3 where work and home phone were stored...
authorkkalev <kkalev>
Mon, 12 Aug 2002 13:08:20 +0000 (13:08 +0000)
committerkkalev <kkalev>
Mon, 12 Aug 2002 13:08:20 +0000 (13:08 +0000)
* Set personal information attributes in lib/sql/user_info.php3 to default values.
* Add a page to change the user's personal information. Changed the user toolbar and added htdocs/user_info.php3
  along with lib/{sql,ldap}/change_info.php3
* Print a message if we can't connect to the ldap server in lib/ldap/user_info.php3

Changelog
htdocs/user_info.php3 [new file with mode: 0644]
html/user_toolbar.html.php3
lib/ldap/change_info.php3 [new file with mode: 0644]
lib/ldap/user_info.php3
lib/sql/change_info.php3 [new file with mode: 0644]
lib/sql/create_user.php3
lib/sql/user_info.php3

index 4b9ce16c99536f7d84e8e4ac854171ca7f0e68d8..fe81ca3c3e90b736f66b14257b26d926c525427f 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,11 @@ Ver 1.50:
 * Updated TODO
 * Added a help page for the Session Timeout and Idle Timeout attributes.
 * The new group page should only be available if the general library type is sql.
+* Fix a small bug in lib/sql/create_user.php3 where work and home phone were stored in the wrong fields.
+* Set personal information attributes in lib/sql/user_info.php3 to default values.
+* Add a page to change the user's personal information. Changed the user toolbar and added htdocs/user_info.php3
+  along with lib/{sql,ldap}/change_info.php3
+* Print a message if we can't connect to the ldap server in lib/ldap/user_info.php3
 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/htdocs/user_info.php3 b/htdocs/user_info.php3
new file mode 100644 (file)
index 0000000..f7096ef
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+require('../conf/config.php3');
+?>
+
+<html>
+<head>
+<title>Personal information 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/user_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">Personal information for <?php echo "$login ($cn)"?></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 ($change == 1){
+       if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
+               include("../lib/$config[general_lib_type]/user_info.php3");
+       if (is_file("../lib/$config[general_lib_type]/change_info.php3"))
+               include("../lib/$config[general_lib_type]/change_info.php3");
+}
+
+if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
+       include("../lib/$config[general_lib_type]/user_info.php3");
+?>
+   <form method=post>
+      <input type=hidden name=login value="<?php echo $login?>">
+      <input type=hidden name=change 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 bgcolor="#d0ddb0">
+               Name (First Name Surname)
+               </td><td>
+               <input type=text name="Fcn" value="$cn" size=35>
+               </td>
+       </tr>
+       <tr>
+               <td align=right bgcolor="#d0ddb0">
+               Mail
+               </td><td>
+               <input type=text name="Fmail" value="$mail" size=35>
+               </td>
+       </tr>
+       <tr>
+               <td align=right bgcolor="#d0ddb0">
+               Departement
+               </td><td>
+               <input type=text name="Fou" value="$ou" size=35>
+               </td>
+       </tr>
+       <tr>
+               <td align=right bgcolor="#d0ddb0">
+               Home Phone
+               </td><td>
+               <input type=text name="Fhomephone" value="$homephone" size=35>
+               </td>
+       </tr>
+       <tr>
+               <td align=right bgcolor="#d0ddb0">
+               Work Phone
+               </td><td>
+               <input type=text name="Ftelephonenumber" value="$telephonenumber" size=35>
+               </td>
+       </tr>
+       <tr>
+               <td align=right bgcolor="#d0ddb0">
+               Mobile Phone
+               </td><td>
+               <input type=text name="Fmobile" value="$mobile" size=35>
+               </td>
+       </tr>
+EOM;
+?>
+       </table>
+<br>
+<input type=submit class=button value="Change" OnClick="this.form.change.value=1">
+</form>
+       </td></tr>
+</table>
+</tr>
+</table>
+</body>
+</html>
index 456a6387cee7772b78fdd5174cebd38cbccb8597..e8aa90952acd7ab87f46b3e9f953b138a7bc786a 100644 (file)
@@ -5,6 +5,10 @@ print <<<EOM
 <a href="user_admin.php3?login=$login" title="Show User Information"><font color="white"><b>SHOW</b></font></a></td>
 <td align=center bgcolor="black" width=100>
 <a href="user_edit.php3?login=$login" title="Change User Dialup Settings"><font color="white"><b>EDIT</b></font></a></td>
+<td align=center bgcolor="black" width=200 colspan=2>
+<a href="user_info.php3?login=$login" title="Change User Personal Information"><font color="white"><b>USER INFO</b></font></a></td>
+</tr>
+<tr valign=top>
 <td align=center bgcolor="black" width=100>
 <a href="user_accounting.php3?login=$login" title="Show User Accounting Information"><font color="white"><b>ACCOUNTING</b></font></a></td>
 <td align=center bgcolor="black" width=100>
diff --git a/lib/ldap/change_info.php3 b/lib/ldap/change_info.php3
new file mode 100644 (file)
index 0000000..48e10d0
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+       $ds = @ldap_connect($config[ldap_server]);
+       if ($ds){
+               $r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+               if ($r){
+                       if ($Fcn != '' && $Fcn != $cn)
+                               $mod['cn'] = $Fcn;
+                       if ($Fmail != '' && $Fmail != $mail)
+                               $mod['mail'] = $Fmail;
+                       if ($Fou != '' && $Fou != $ou)
+                               $mod['ou'] = $Fou;
+                       if ($Ftelephonenumber != '' && $Ftelephonenumber != $telephonenumber)
+                               $mod['telephonenumber'] = $Ftelephonenumber;
+                       if ($Fhomephone != '' && $Fhomephone != $homephone)
+                               $mod['homephone'] = $Fhomephone;
+                       if ($dn != ''){
+                               @ldap_mod_replace($ds,$dn,$mod);
+                               if (@ldap_error($ds) != 'Success')
+                                       echo "<b>LDAP ERROR: " . ldap_error($ds) . "</b><br>\n";
+                               else
+                                       echo "<b>User personal information updated successfully</b><br>\n";
+                       }
+               }
+               @ldap_close($ds);
+       }
+?>
index 34fd632c49298186bdd70051a334e114e0409d1f..174f72eaa8cc3eac66839d38fd2037b673dc4c0f 100644 (file)
@@ -46,4 +46,6 @@ if ($ds) {
        }
        @ldap_close($ds);
 }
+else
+       echo "<b>Could not connect to the LDAP server</b><br>\n";
 ?>
diff --git a/lib/sql/change_info.php3 b/lib/sql/change_info.php3
new file mode 100644 (file)
index 0000000..ddf05dd
--- /dev/null
@@ -0,0 +1,50 @@
+<?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);
+$fail = 0;
+if ($link){
+       if ($config[sql_use_user_info_table] == 'true'){
+               $res = @da_sql_query($link,$config,
+               "SELECT UserName FROM $config[sql_user_info_table] WHERE
+               UserName = '$login';");
+               if ($res){
+                       if (!@da_sql_num_rows($res,$config)){
+                               $res = @da_sql_query($link,$config,
+                               "INSERT INTO $config[sql_user_info_table]
+                               (UserName,Name,Mail,Department,HomePhone,WorkPhone,Mobile) VALUES
+                               ('$login','$Fcn','$Fmail','$Fou','$Ftelephonenumber','$Fhomephone','$Fmobile');");
+                               if (!$res || !@da_sql_affected_rows($link,$res,$config)){
+                                       echo "<b>Could not add user information in user info table</b><br>\n";
+                                       $fail = 1;
+                               }
+                       }
+                       else{
+                               $res = @da_sql_query($link,$config,
+                               "UPDATE $config[sql_user_info_table] SET Name = '$Fcn',Mail = '$Fmail',
+                               Department = '$Fou', HomePhone = '$Fhomephone', WorkPhone = '$Ftelephonenumber',
+                               Mobile = '$Fmobile';");
+                               if (!$res || !@da_sql_affected_rows($link,$res,$config)){
+                                       echo "<b>Could not update user information in user info table</b><br>\n";
+                                       $fail = 1;
+                               }
+                       }
+               }
+               else{
+                       echo "<b>Could not find user in user info table. SQL Error</b><br>\n";
+                       $fail = 1;
+               }
+               if ($fail == 0)
+                       echo "<b>User information updated successfully</b><br>\n";
+       }
+       else
+               echo "<b>Cannot use the user info table. Check the sql_use_user_info_table directive in admin.conf</b><br>\n";
+       
+}
+else
+       echo "<b>Could not connect to database</b><br>\n";
+?>
index 012850a873af3172ddbe1e0d8932632ca8bca780..3a26ce3ae77aa3a60b1e667d34b453ca5ca7e4b7 100644 (file)
@@ -32,7 +32,7 @@ if ($link){
                                        $res = @da_sql_query($link,$config,
                                        "INSERT INTO $config[sql_user_info_table]
                                        (UserName,Name,Mail,Department,HomePhone,WorkPhone,Mobile) VALUES
-                                       ('$login','$cn','$mail','$ou','$telephonenumber','$homephone','$mobile');");
+                                       ('$login','$cn','$mail','$ou','$homephone','$telephonenumber','$mobile');");
                                        if (!$res || !@da_sql_affected_rows($link,$res,$config))
                                                echo "<b>Could not add user information in user info table</b><br>\n";
                                }
index be6efb822e537e527016841171835392be2fd4d9..3da8cc4ad95354d2f6bf61d176606ef3b43c7d2b 100644 (file)
@@ -14,6 +14,17 @@ if ($config[sql_use_operators] == 'true'){
        $use_op = 0;
 }
 $user_exists = 'no';
+
+$cn_lang = '-';
+$homeaddress = '-';
+$homeaddress_lang = '-';
+$fax = '-';
+$url = '-';
+$ou_lang = '-';
+$title = '-';
+$title_lang = '-';
+$mailalt = '-';
+
 unset($item_vals);
 unset($tmp);
 $link = @da_sql_pconnect($config);