Merging Scribus and Nighthawk repositories... Mercurial saves the day...again :-)
authorDan
Tue, 10 Jul 2007 00:40:52 -0400
changeset 58 8f532d8ab5f5
parent 48 fc9762553a3c (diff)
parent 57 b354deeaa4c4 (current diff)
child 59 7c4a851fb5c5
Merging Scribus and Nighthawk repositories... Mercurial saves the day...again :-)
--- a/includes/email.php	Mon Jul 09 22:01:27 2007 -0400
+++ b/includes/email.php	Tue Jul 10 00:40:52 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	Mon Jul 09 22:01:27 2007 -0400
+++ b/includes/functions.php	Tue Jul 10 00:40:52 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>');
 
 ?>