View Single Post
  #264  
Old 03-16-2006, 04:02 PM
dkendall dkendall is offline
 
Join Date: Mar 2006
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01182 seconds
  • Memory Usage 1,777KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete