CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Obfuscate (Munge) Email

Print topic Send  topic

Author Message
maxhugen

Posts: 272
Posted: 08/25/2008, 6:11 PM

In a Grid with a list of Suppliers, I'm displaying Address, Website, Tel etc.

I'd like to add Email as well, but they need to be obfuscated to prevent web bots from harvesting them.

Has anyone got any suggestions about how to go about this pls?

MTIA
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/25/2008, 6:34 PM

http://techblog.tilllate.com/2008/07/20/ten-methods-to-...esses-compared/
Have you ever seen this?

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/25/2008, 7:02 PM

Fantastic! Already spent hours trying to write my own functions and algorithms... and although I was getting there, it was way ugly!

Really like the simplicity of the CSS solutions, so I'll look at transforming the email address in the BeforeShowRow event to suit one of the 2 CSS tricks described.

Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/25/2008, 8:56 PM

In case anyone is interested....

The CSS methods at http://techblog.tilllate.com/2008/07/20/ten-methods-to-...esses-compared/ don't work if you want the email address displayed as a link, which is no doubt why they were displayed as static text only at http://ch.tilllate.com/061101_emailtest.php

So I went with the ROT13 method:

1. Assuming you have built a Grid, one field of which is called 'email', first change this Label's Content property from Text to HTML.

2. Add 'custom code' to the BeforeShowRow event of your Grid (in this example the Grid is called 'List'):
    if ($List->email->GetValue()) {  
        $munged = gl_MungeEmail($List->email->GetValue());  
        $List->email->SetValue($munged);  
    }
3. Add the 'munge' function at the end of the yourPage_events.php code page (or your own 'custom functions' php page):
function gl_MungeEmail($address) {  
    // see http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/  
    // and http://ch.tilllate.com/061101_emailtest.php  
  
    // construct link  
    $link = "<a href='mailto:".$address."' rel='nofollow'>".$address."</a>";  
  
    // perform the ROT13 encoding, see http://ch2.php.net/str_rot13  
    $rot13 = str_rot13($link);  
  
    // construct the javascript code which 'unmunges' the ROT13  
    $retval = "<script type='text/javascript'>"  
            . "document.write(\""  
            . $rot13  
            . "\".replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<='Z'?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));"  
            . "</script>";  
    return $retval;  
}

Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/26/2008, 2:46 AM

Good job Max.
And thanks for 'The Beer'.

Hints:
If you need to Munge at more than one page, either create a functions directory in your projects directory and store a file 'fn_mungemail.php' (arbitrary name) there, containing your above function (3.).
Then when you need the function, Page After Initialize,
  
require_once('functions/fn_mungemail.php');  
will make the '2.'custom code work unchanged.
Saves you doing '3.'
As well as accidentaly erasing it when you loose an _event file.

Walter
(Puts the froth on the beer)
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/26/2008, 4:53 AM

Yep, I figured having a custom 'function' php page was a good idea, so I've moved all my own functions to an include php file, and then include it in the AfterInitialize event (it's in my template now).

Bottoms up! Or should I say 'Proost' ?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
datadoit
Posted: 08/26/2008, 5:45 AM

Thanks Max!
wkempees


Posts: 1679
Posted: 08/26/2008, 6:50 AM

Proost!
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
DonP
Posted: 08/27/2008, 12:00 PM

If the email addresses are stored inside the database and are being
pulled out on-the-fly, I am not sure that they will be visible to Web
bots. As I understand it, a Web bot can scan the individual files but
without actually loading the file into a browser, all they should see is
the code. Am I missing something here?

Don (DonP)

maxhugen wrote:
> In a Grid with a list of Suppliers, I'm displaying Address, Website, Tel etc.
>
> I'd like to add Email as well, but they need to be obfuscated to prevent web
> bots from harvesting them.
>
> Has anyone got any suggestions about how to go about this pls?
>
> MTIA
> _________________
> Max (95% CCS Newbie)
> "I have a dream..." that CCS provided a php debugger.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
maxhugen

Posts: 272
Posted: 08/27/2008, 5:48 PM

Hi Don

If I have a Suppliers.php page, bots can find it either by traversing the website's links to it, or by pulling every file in my web server's directory. I know Google (at least) does the latter, as it's indexed 'test' pages I had there previously.

Once they have a list of pages, they can issue an http request for the page... so my Suppliers page now is sent "filled in" with the data - including any email addresses - in html format.

I have seen code for bots which do this (issue http request)...

Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
DonP
Posted: 08/28/2008, 12:22 PM

Is there a way of obfuscating that does not involve JavaScript and that
works only on the address itself without creating any link? I've not had
any luck so far in modifying the one here to do that.

Don (DonP)

maxhugen wrote:
> Hi Don
>
> If I have a Suppliers.php page, bots can find it either by traversing
> the website's links to it, or by pulling every file in my web server's
> directory. I know Google (at least) does the latter, as it's indexed 'test'
> pages I had there previously.
>
> Once they have a list of pages, they can issue an http request for the page...
> so my Suppliers page now is sent "filled in" with the data - including any email
> addresses - in html format.
>
> I have seen code for bots which do this (issue http request)...
>
> Cheers, Max
> _________________
> Max (93% CCS Newbie)
> "I have a dream..." that CCS provided a php debugger.
> www.chrisarminson.com | www.eipdna.com | www.gardenloco.com (coming... one
> day...)
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
maxhugen

Posts: 272
Posted: 08/28/2008, 4:11 PM

Hi Don
Quote :
The CSS methods at
http://techblog.tilllate.com/2008/07/20/ten-methods-to-...esses-compared/ don't work if you want the email address displayed as a link, which is no doubt why they were displayed as static text only at http://ch.tilllate.com/061101_emailtest.php

Both the CSS methods worked really well (and easily), if you don't want the link itself! And, no javascript.

Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/28/2008, 4:45 PM

Singing: "You took the words right out of my mouth"
(Meatloaf)

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
DonP
Posted: 08/28/2008, 5:42 PM

I had tried the first link as above from the earlier posting but it went
to a page with nothing it but some women (who themselves had little on);
the second link does show examples but they appear to all be JavaScript
or CSS. I don't want CSS either, just plain PHP. Seems that it should be
relatively easy to do so I'll research it.

Don (DonP)

maxhugen wrote:
> Hi Don
>
>
Quote :
The CSS methods at
> http://techblog.tilllate.com/2008/07/20/ten-methods-to-...esses-compared/ don't
> work if you want the email address displayed as a link, which is no doubt why
> they were displayed as static text only at
> http://ch.tilllate.com/061101_emailtest.php[/quote]
>
> Both the CSS methods worked really well (and easily), if you don't want the
> link itself! And, no javascript.
>
> Cheers, Max
> _________________
> Max (93% CCS Newbie)
> "I have a dream..." that CCS provided a php debugger.
> www.chrisarminson.com | www.eipdna.com | www.gardenloco.com (coming... one
> day...)
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.