By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,637 Members | 3,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,637 IT Pros & Developers. It's quick & easy.

Hiding email addresses - rot13

P: n/a
Nel
Before I try and reinvent the wheel, can anyone help me with a basic routine
to hide email addresses from harvesting.

I currently use pull my page content from a db and run this ereg_replace:
$pagetext=ereg_replace('[A-Za-z0-9_]([-._]?[A-Za-z0-9])*@[A-Za-z0-9]([-.]?[A
-Za-z0-9])*\.[A-Za-z]+', '<a href="mailto:\\0"><font
color="#0000FF"><b>\\0</b></font></a>', $pagetext);

This simply replaces any emails within the page text with an <a> tag.

What I would like to do is replace it with:
<script language="JavaScript">
document.write(rot13('<n
uers=\"zn**@rknzcyr.pbz\">zn**@rknzcyr.pbz</n>'));
</script>

So, somehow I need to PHP's str_rot13() on the email addresses before the
ereg_replace. If anyone can suggest a solution I would be grateful.

Nel
Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Nel" <ne***@ne14.co.NOSPAMuk> wrote in message
news:r6*********************@wards.force9.net...
Before I try and reinvent the wheel, can anyone help me with a basic routine to hide email addresses from harvesting.

I currently use pull my page content from a db and run this ereg_replace:
$pagetext=ereg_replace('[A-Za-z0-9_]([-._]?[A-Za-z0-9])*@[A-Za-z0-9]([-.]?[A -Za-z0-9])*\.[A-Za-z]+', '<a href="mailto:\\0"><font
color="#0000FF"><b>\\0</b></font></a>', $pagetext);

This simply replaces any emails within the page text with an <a> tag.

What I would like to do is replace it with:
<script language="JavaScript">
document.write(rot13('<n
uers=\"zn**@rknzcyr.pbz\">zn**@rknzcyr.pbz</n>'));
</script>

So, somehow I need to PHP's str_rot13() on the email addresses before the
ereg_replace. If anyone can suggest a solution I would be grateful.

Nel


Use preg_replace_callback.
Jul 17 '05 #2

P: n/a
Nel
"Chung Leong" <ch***********@hotmail.com> wrote in message
news:3b********************@comcast.com...
"Nel" <ne***@ne14.co.NOSPAMuk> wrote in message
news:r6*********************@wards.force9.net...
Before I try and reinvent the wheel, can anyone help me with a basic

routine
to hide email addresses from harvesting.

I currently use pull my page content from a db and run this ereg_replace:

$pagetext=ereg_replace('[A-Za-z0-9_]([-._]?[A-Za-z0-9])*@[A-Za-z0-9]([-.]?[A
-Za-z0-9])*\.[A-Za-z]+', '<a href="mailto:\\0"><font
color="#0000FF"><b>\\0</b></font></a>', $pagetext);

This simply replaces any emails within the page text with an <a> tag.

What I would like to do is replace it with:
<script language="JavaScript">
document.write(rot13('<n
uers=\"zn**@rknzcyr.pbz\">zn**@rknzcyr.pbz</n>'));
</script>

So, somehow I need to PHP's str_rot13() on the email addresses before the ereg_replace. If anyone can suggest a solution I would be grateful.

Nel


Use preg_replace_callback.

I have looked at the PHP manual for preg_replace_callback and don't
understand how I can replace the text and then str_rot13 within the same
line. Can anyone offer a simple solution using my original ereg string?

Whilst I am at it, is there a better, quicker or easier way to hide an email
address from harvesters?

Nel
Jul 17 '05 #3

P: n/a
I noticed that Message-ID: <nG*********************@wards.force9.net>
from Nel contained the following:
Whilst I am at it, is there a better, quicker or easier way to hide an email
address from harvesters?


Yup. Use a response form.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

P: n/a
Nel
"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:72********************************@4ax.com...
I noticed that Message-ID: <nG*********************@wards.force9.net>
from Nel contained the following:
Whilst I am at it, is there a better, quicker or easier way to hide an emailaddress from harvesters?


Yup. Use a response form.


I would really like to keep the email address visible to the reader, but
make it hard for spambots.
<script language="JavaScript">
<!--
var name = "test";
var domain = "email.com";
document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
document.write(name + '@' + domain + '</a>');
//-->
</script>

This would do if I could generate this on the fly from php.

Nel
Jul 17 '05 #5

P: n/a
I noticed that Message-ID: <DD*********************@wards.force9.net>
from Nel contained the following:
Yup. Use a response form.


I would really like to keep the email address visible to the reader, but
make it hard for spambots.
<script language="JavaScript">

Any solution requiring javascript will also make it hard for anyone
browsing with high security.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

P: n/a
Nel

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:u1********************************@4ax.com...
I noticed that Message-ID: <DD*********************@wards.force9.net>
from Nel contained the following:
Yup. Use a response form.


I would really like to keep the email address visible to the reader, but
make it hard for spambots.
<script language="JavaScript">

Any solution requiring javascript will also make it hard for anyone
browsing with high security.


I must admit, I did worry about that a bit. What about a way to change the
email address in to html special chars?
e.g.
<a
href="mailto:%74%65%73%74%40%65%78%61%6d%70%6c%65% 2e%63%6f%6d">te&
#115;t@example.co&#1
09;</a>

I can write a script to do this where $email =
emailhide("te**@example.com"); but not sure how to do this for multiple
emails withing a text string.

Nel
Jul 17 '05 #7

P: n/a
I noticed that Message-ID: <Eq*********************@wards.force9.net>
from Nel contained the following:
Any solution requiring javascript will also make it hard for anyone
browsing with high security.


I must admit, I did worry about that a bit. What about a way to change the
email address in to html special chars?


Depends on what is being used to harvest the addresses. If a browser
can parse it then it's conceivable that this facility may be written
into the harvester. I'd say even more likely because such obfuscation
must mean a valid address.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8

P: n/a
Regarding this well-known quote, often attributed to Nel's famous "Wed, 28
Apr 2004 11:02:43 +0100" speech:
"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:u1********************************@4ax.com...
I noticed that Message-ID: <DD*********************@wards.force9.net>
from Nel contained the following:
Yup. Use a response form.

I would really like to keep the email address visible to the reader, but
make it hard for spambots.
<script language="JavaScript">

Any solution requiring javascript will also make it hard for anyone
browsing with high security.


I must admit, I did worry about that a bit. What about a way to change the
email address in to html special chars?
e.g.
<a
href="mailto:%74%65%73%74%40%65%78%61%6d%70%6c%65% 2e%63%6f%6d">te&
#115;t@example.co&#1
09;</a>

I can write a script to do this where $email =
emailhide("te**@example.com"); but not sure how to do this for multiple
emails withing a text string.

Nel


I've always liked using a "gatekeeper" page. It's a simple form with a
button, maybe a textbox and a simple question. They fill it in, or just
click the button, they get the email address. I've even put some simple
onload javascript in there that automatically submits the form. People with
JS on just see a small blip before the page hits. Most spambots won't
bother with it, since time is money, and who cares.

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.