Display of username on login screen
Alexander Skwar
ASkwar@DigitalProjects.com
Wed, 10 Oct 2001 00:16:11 +0200
Hi
On the login screen (horde/login.php), only the username of the logged
in user is displayed. I'd like it better, if also the real name would
be displayed, if one is set in the /etc/passwd GECOS entry.
Attached is a diff which does just this. It displays the user's real
name, if the function posix_getpwnam is available. If so, the function
returns the real name. It further also returns other "useful"
information like phone number, etc.pp.. Per standard, these fields
should be seperated by commas (,). The diff actually only returns the
very first comma set, so, if someone has his username specified like
"Doe, John", it would only print "Doe".
If no realname is set, or if the function does not exist, the username
is displayed, like it was before.
--- user.inc.alt Tue Oct 9 23:58:18 2001
+++ user.inc Wed Oct 10 00:14:43 2001
@@ -1,7 +1,25 @@
+<?php
+function getRealname($username){
+ // Try to get the GECOS name entry for the user
+ if (function_exists('posix_getpwnam')){
+ $pwnam = posix_getpwnam($username);
+ // We're only interested in the very first part
+ // hoping, that this really contains the user's
+ // real name
+ $realname = explode(',', $pwnam['gecos']);
+ if (! empty($realname[0])){
+ return ucwords($realname[0]) . ' <' . $username . '>';
+ }
+ }
+ // Function does not exist or no realname set,
+ // return the username
+ return ucfirst($username);
+}
+?>
<table class="menu" border="0" width="100%" cellpadding="0"
cellspacing="0">
<tr valign="middle">
<td class="header" align="left" nowrap="nowrap">
- <b><?= sprintf(_("Welcome, %s"), ucfirst(Auth::getAuth())) ?></b>
+ <b><?= sprintf(_("Welcome, %s"),
getRealname(Auth::getAuth())) ?></b>
</td>
<td width="100%"> </td>
<td class="header" align="center" nowrap="nowrap">
Alexander Skwar
--
How to quote: http://learn.to/quote (de) http://quote.6x.to (en)
Homepage: http://www.digitalprojects.com | http://www.iso-top.de
iso-top.de - Die günstige Art an Linux Distributionen zu kommen
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/