I implemented the e-mail address masking feature mentioned earlier in this thread. But we use vBulletin for tech suport, and sometimes we post messages telling users to e-mail us directly.
So I've tweaked the masking feature so that it does not strip out addresses from certain domains.
I've also made it configurable in the NNTP Gateway Settings by adding these variables:
Code:
Title: Email Address Mask
Varname: email_address_mask
Value: \1 (AT) \2 (DOT) \3
Description: Mask for obfusicating email addresses in imported messages.
Title: Mask Email Exclude
Varname: mask_email_exclude
Value: onedomain.com;domaintwo.net;third.org
Description: Semicolon-delimited lowercase list of domains for which e-mail addresses should NOT be masked.
In
gateway.php locate the line
logging("Gateway version "... and insert this beneath it:
Code:
// Get email mask settings
$email_address_mask = $nntp_settings['email_address_mask'];
$mask_email_exclude = explode(';', $nntp_settings['mask_email_exclude']);
Locate the following block of code:
Code:
//Hide real email address for mailing lists
if ($nntp['grouptype'] == 'mail')
{
$message['text'] = preg_replace('/([-_.\\w]+)@([\\w]+[-\\w]+)\\./', '\\1 (AT) \\2 (DOT) ', $message['text']);
}
Replace it with this:
Code:
//Mask real email addresses in message text
if (isset($email_address_mask))
$message['text'] = preg_replace_callback('/(.+)@([a-zA-Z0-9\.]+)/', "mask_email_callback", $message['text']);
A few lines later, after the call to
from_name, add the following code:
Code:
//clean up name
if (isset($email_address_mask))
$from_name = preg_replace('/(.+)@(.+)/', '\\1', $from_name);
NOTE: This handles the case where the display name in the nntp posting is an e-mail address. It simply changes
my.name@domain.com to
my.name, rather than using the
email_address_mask value and without regard to the
mask_email_exclude setting.
Finally, add this code to the end of
functions_nntp.php:
Code:
function mask_email_callback($parts)
{
global $email_address_mask;
global $mask_email_exclude;
if (in_array(strtolower($parts[2]), $mask_email_exclude))
return $parts[0];
return preg_replace('/(.+)@(.+)\\.([^\\.]+)/', $email_address_mask, $parts[0]);
}
This will replace "
my.name@my.domain.com" with "
my.name (AT) my.domain (DOT) com". Of course, you can change the
email_address_mask value to anything (e.g., "\1@..."). Leaving it blank will disable this feature.
David