E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
--- a/includes/email.php Fri Jul 06 11:04:38 2007 -0400
+++ b/includes/email.php Fri Jul 06 11:45:50 2007 -0400
@@ -595,7 +595,19 @@
function mask_address($email)
{
- return str_replace('.', ' <DOT> ', str_replace('@', ' <AT> ', $email));
+ $at = array(' (AT) ', ' __AT__ ', ' *AT* ', ' [AT] ', ' <AT> ', ' <__AT__> ');
+ $dot = array(' (DOT) ', ' __DOT__ ', ' *DOT* ', ' [DOT] ', ' <DOT> ', ' <__DOT__> ');
+ while(strstr($email, '@'))
+ {
+ $my_at = $at[ array_rand($at) ];
+ $email = str_replace_once('@', $my_at, $email);
+ }
+ while(strstr($email, '.'))
+ {
+ $my_dot = $dot[ array_rand($dot) ];
+ $email = str_replace_once('.', $my_dot, $email);
+ }
+ return $email;
}
/**
--- a/includes/functions.php Fri Jul 06 11:04:38 2007 -0400
+++ b/includes/functions.php Fri Jul 06 11:45:50 2007 -0400
@@ -2298,6 +2298,31 @@
return false;
}
+/**
+ * Replaces the FIRST given occurrence of needle within haystack with thread
+ * @param string Needle
+ * @param string Thread
+ * @param string Haystack
+ */
+
+function str_replace_once($needle, $thread, $haystack)
+{
+ $needle_len = strlen($needle);
+ for ( $i = 0; $i < strlen($haystack); $i++ )
+ {
+ $test = substr($haystack, $i, $needle_len);
+ if ( $test == $needle )
+ {
+ // Got it!
+ $upto = substr($haystack, 0, $i);
+ $from = substr($haystack, ( $i + $needle_len ));
+ $new_haystack = "{$upto}{$thread}{$from}";
+ return $new_haystack;
+ }
+ }
+ return $haystack;
+}
+
//die('<pre>Original: 01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>');
?>