Here is a quick mod of the original. Just pass in the entire text block and
it takes care of the rest.

What it is doing is using rematch() to return an array of all email
addresses that it finds in the given string. 

It then loops over that array of email addresses, replacing all occurrences
in the given string, with the ascii encoded equivalent (the inner loop is
what I sent last time).

<cfscript>
        function disguiseEmails(str){
                
                var emailArr =
rematch("([[:alnum:]_\.\-]+@([[:alnum:]_\.\-]+\.)+(museum|travel|[[:alpha:]]
{2,4}))", str);
                var     thisEmailAddr = "";
                var i = 1;
                var ii = 1;
                
                for (i=1; i <= arraylen(emailArr); i++)
                {
                        for (ii=1; ii <= len(emailArr[i]); ii++)
                        {
                                thisEmailAddr = thisEmailAddr & "&##" &
asc(mid(emailArr[i], ii, 1));
                        }
                        str = replace(str, emailArr[i], thisEmailAddr,
'all');
                }               
                
                return str;
        }
</cfscript>



.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
http://cf4em.com





-----Original Message-----
From: Jenny Gavin-Wear [mailto:jenn...@fasttrackonline.co.uk] 
Sent: Saturday, October 08, 2011 5:40 AM
To: cf-talk
Subject: RE: Hiding email address from spiders


Thanks, Bobby, exactly along the lines I am thinking.

The mail address for me has no mailto:, it's just contained in a string.
I'm wondering if I'll have to check the whole string for the existance of an
email address by looping through each "word", or if there is an
easier/faster way?

For example, this code would find the string.  However, I don't know if I
can use a regular expression, for example, to rereplace the string with
ascii?  (Never used regex before...)

Or could I use a regular expression to search AND replace the email address
with ascii on the whole string, which would be a lot faster?

<cfset mystring = "this is the email address myaddr...@home.com that I use">
<cfset mynewString = "">
<cfoutput>
<cfloop from="1" to="#listlen(mystring, " ")#" index="I">
<cfif  isvalid("email", listgetat(mystring, I, " "))>
<!--- now set this to ascii --->
#listgetat(mystring, I, " ")#<br>
<cfelse>
<cfset mynewString = "#mynewString# #listgetat(mystring, I, " ")#">
</cfif>
</cfloop>
#mynewString#
</cfoutput>


Jenny Gavin-Wear
Fast Track Online
Tel: 01262 602013
http://www.fasttrackonline.co.uk/


>>-----Original Message-----
>>From: Bobby Hartsfield [mailto:bo...@acoderslife.com]
>>Sent: 08 October 2011 04:09
>>To: cf-talk
>>Subject: RE: Hiding email address from spiders
>>
>>
>>
>>Here is a page with an example of the source:
>>
>>http://cf4em.com/cf4em/index.cfm?mainaction=posts&forumid=2&threadid=63
>>
>>The last post has my email address in the last sentence. This is what the
>>source of that mailto link looks like:
>>
>><a
>>href="&#109&#97&#105&#108&#116&#111&#58&#98&#111&#98&#98&#121&#64&
>>#99&#102&#
>>52&#101&#109&#46&#99&#111&#109">&#98&#111&#98&#98&#121&#64&#99&#10
>>2&#52&#101
>>&#109&#46&#99&#111&#109</a>
>>
>>
>>.:.:.:.:.:.:.:.:.:.:.:.:.
>>Bobby Hartsfield
>>http://acoderslife.com
>>http://cf4em.com
>>
>>


--
I am using the free version of SPAMfighter.
We are a community of 7 million users fighting spam.
SPAMfighter has removed 4302 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

The Professional version does not have this message






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:348015
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to