FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Mask usernames?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Mask usernames? [message #39325] Wed, 17 October 2007 20:57 Go to next message
pgregg is currently offline  pgregg   United Kingdom
Messages: 14
Registered: July 2006
Karma: 0
Junior Member
I've integrated FUD into a tech support website using a single sign on - BUT - the users login with their email address which is great except that posts now give away the customer's email address.

I understand that you can use the "alias" feature to hide this, but not all users do this, so what I would like to do in the output is to filter the username through a function by replacing their domain name with ****. I can write the function / preg_replace no problem - I just need to know where to put it and call it.

Thanks,
PG
Re: Mask usernames? [message #39360 is a reply to message #39325] Fri, 19 October 2007 00:07 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Most of the user name renderings are done via the draw_user_link() function inside ulink.inc.t. So that would be the best place for your regex.

FUDforum Core Developer
Re: Mask usernames? [message #39381 is a reply to message #39360] Fri, 19 October 2007 10:13 Go to previous messageGo to next message
pgregg is currently offline  pgregg   United Kingdom
Messages: 14
Registered: July 2006
Karma: 0
Junior Member
Welcome back - glad all the spam is gone now. Figured you were on vacation with the IRC "idle 176 hours" Smile

It looks like draw_user_link() is only used in the 'who is logged in' and 'what people are doing' - it isn't used in the Forum/Category listing's "last post by", nor is it used in the actual message display or user's profile page.

I found in drawmsg.inc.t and drawpmsg.inc.t references outputting $user_login (which I can regex easily) and directly outputing $obj->alias in the template (thinking I could do a $user_login = $obj->alias; in drawpmsg.inc.t and change the template to $user_login much the same way as drawmsg.inc.t works). Haven't figured out the profile page yet.

But, I'm consious that this gets right into the core of FUDforum and will limit any ability to upgrade. Ideally I'd like minimal core code impact (maybe a standard output hook/filter for a custom function we can stick at the bottom of GLOBALS.php)?

e.g. in drawmsg.inc.t Line 157:
$user_login = $obj->user_id ? $obj->login : $GLOBALS['ANON_NICK'];

add:
if (function_exists('output_filter_userlogin'))
$user_login = output_filter_userlogin($user_login);

in my GLOBALS.php:
/* DO NOT EDIT FILE BEYOND THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING */
require($INCLUDE.'core.inc');

// borland additions - pgregg
function output_filter_userlogin($user_login) {
// pgregg modification to protect email address of users (when used as a login)
if (strpos($user_login, '@') !== false)
$user_login = preg_replace('#@.*?\.(\w+)$#', '@###.\\1', $user_login);
return $user_login;
}

Do you think something like this is valueable in the core code?

Cheers,
PG
Re: Mask usernames? [message #39396 is a reply to message #39381] Sun, 21 October 2007 15:48 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You are correct, the function is not used in all places, but it is a good place to start since most key pages, like member list, message display and "who's online" already use it. The two places that don't, the "last post bit" and the user profile page, can be modified to use that function as well for output.

I wouldn't put any code into globals.php as it is a predominantly a configuration file. Any super-common functions should be put inside core.inc inside the include directory.


FUDforum Core Developer
Re: Mask usernames? [message #39404 is a reply to message #39396] Sun, 21 October 2007 18:08 Go to previous messageGo to next message
pgregg is currently offline  pgregg   United Kingdom
Messages: 14
Registered: July 2006
Karma: 0
Junior Member
Are you sure about message display? (drawpmsg.inc.t/private_message_entry calls $obj->alias raw) I don't see it being called there at all. The other two places, who's online and user list I have turned off as I don't want other users knowing who is online or even who the members are - I'll leave it up to the users themselves to reveal themselves if they want.

So it looks like draw_user_link() isn't called anywhere where I need it to be - would it be better to ensure this function is called from anywhere where the username is going to be output (message display, last post by, profile, etc) and to get this change into CVS?

Thanks,
PG
Re: Mask usernames? [message #39447 is a reply to message #39404] Mon, 22 October 2007 22:51 Go to previous message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Hrm you're right, I guess I didn't convert the code to use the method yet. So for now you'll need to patch drawmsg.tmpl and drawpmsg.tmpl as well. Sorry.

FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to make index.php RDF button stick to the category in the URL?
Next Topic: Protect a non Fud page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 09 02:10:58 GMT 2024

Total time taken to generate the page: 0.02435 seconds