"Justin Koivisto" <justin@koivi.com> wrote in message
news:e7myd.712$CB.22799@news7.onvoy.net...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Kerberos wrote:
> | Neat article on how to hide e-mail addresses from spambots:
> | http://www.phoenity.com/newtedge/hide_email_spambots/
> | To date I have always used a Javascript, but it doesn't work with
> | XHTML, however this CSS hack works fine with XHTML, and will protect
> | e-mail addresses from being collected.
> |
>
> I've had good luck so far with this:
>
> /**
> * emailEncode
> *
> * Spits out email addresses using HTML entities instead of the actual
> * characters as an attempt to prevent spam to these addresses.
> * Searches for email addresses, links them, and encodes them.
> *
> * @param $x The content that contains the email address(es)
> * @result Returns the input with addresses encoded
> */
> function emailEncode($x){
> ~ $pattern='/([a-z][a-z0-9_.-\/\%]*@[^\s\"\)\?<>]+\.[a-z]{2,6})/i';
> ~ $search=array();
> ~ $replace=array();
> ~ if(preg_match_all($pattern,$x,$matches)){
> ~ if(isset($matches[0])){
> ~ // There should be at least one match from the string.
> ~ for($i=0;$i<count($matches[0]);$i++){
> ~ $search[]=$matches[0][$i];
> ~ $str='';
> ~ for($j=0;$j<strlen($matches[0][$i]);++$j){
> ~ $str.='&#'.ord($matches[0][$i]{$j}).';';
> ~ }
> ~ $replace[]='<a href="mailto:'.$str.'">'.$str.'</a>';
> ~ }
> ~ }
> ~ }
> ~ return str_replace($search,$replace,$x);
> }
>
> I just pass the entire content block into it... It translates
> "spam@koivi.com" to
> "spam@koivi.com"
> ~ (as a link)
Why generate the link on the fly? Just make a local page that converts an
email address to the string you desire, from which you can copy and paste it
into the code for your page. That way there is no need for JavaScript to be
enabled on the user's PC.