Extension:EmailObfuscator

What can this extension do?
This extension obfuscates email addresses in tags. It changes individual characters to their ASCII equivalent codes for html so that spiders ignore them.

Usage
The email address must be specified in this tag format: Some Text.

Installation
To install / test the extension kindly add it to the end of your 'LocalSettings.php' file in your MediaWiki installation folder.

Changes to LocalSettings.php
require_once("/extensions/EmailObfuscator/obfuscate_email.php");

Code
<?php

$wgExtensionFunctions[] = 'obfuscateEmailAddress';
 * 1) Defines the main function to be executed for this extension.

$wgHooks['ParserAfterStrip'][] = 'obfuscateEmailAddress';
 * 1) Sets the hook to be executed once the parser has stripped HTML tags.

function obfuscateEmailAddress { // Declaring the global parser.. global $wgParser;
 * 1) This function initiates the hook for the parser to convert
 * 2) tags to obfuscated email addresses.

// Setting the hook to parse tags from the parser output.. $wgParser->setHook( 'mail', 'startObfuscate' ); }

function startObfuscate( $input, $argv ) { // Obfuscating the 'mailto:' text.. $email_prefix = textObfuscator('mailto:');
 * 1) This function extracts the parameters from the  tags and
 * 2) the text between the and tags and formats them as ""
 * 3) tags and writes them in the document.

// Fetching the 'address' parameter from the tag.. $email = $argv['address'];

// Fetching the description parameter from the tag.. $desc = $argv['description'];

// Checking for a valid email address.. $email = preg_replace("/([\\w\\d\\.\\_]+@[\\w\\d\\.\\_]+)/e", "textObfuscator('\$1')", $email);

// If a description parameter exists.. then obfuscate that too.. if ($desc != '') { // Obfuscate the description since it exists.. $desc = textObfuscator($desc);

// If a description parameter exists then print it in the link.. return "". htmlspecialchars($input). ""; } else { // If a description parameter does not exist then just print the link with the 'mailto' URL.. return "". htmlspecialchars($input). ""; } }

function textObfuscator( $text ) { $output = ""; for( $i=0 ; $i
 * 1) This function does the actual obfuscation