WebAppers

/ best free open source web resources /

Shopify

Protect Your Email Address with PHP Hide_Email()

Posted · Category: License Free, Tools

PHP hide_email() is a PHP function to protect the E-mail address you publish on your website against bots or spiders that index or harvest E-mail addresses for sending you spam. It uses a substitution cipher with a different key for every page load.

PHP hide_email() encrypts your E-mail address and generates the javascript that decrypts it. Most bots and spiders can’t execute javascript and that is what makes this work. A visitor of your web page will not notice that you used this script as long as he/she has javascript enabled. The visitor will see “[javascript protected email address]” in stead of the E-mail address if he/she has javascript disabled.

You can also use the generator if you have no PHP support on your web server. Change the E-mail address into your own E-mail address and press “Generate”. Cut and paste the generated XHTML into your own web page.

php-hide-email

Requirements: -
Demo: http://www.maurits.vdschee.nl/php_hide_email/
License: License Free

13 Comments
  • http://www.subscript.ca Scott MacDonald

    Cool idea… though I really doubt it will take long at all for there to be bots that will start parsing this. The safety lies in the fact that hopefully it doesn’t get too popular, or finding your own ways to slightly tweak it.

  • Fan

    kinda cool… but you could just use gmail and not worry about spam.

  • http://www.steinhaug.no/ Kim Steinhaug

    This is probably a great idea to implement on our customers webpages, as an option for them to enable. Myself I still have doubts about anything that isnt compatible with a none js browser – however I must be thinking like a dinosaur now.

    I used that argument like 5 years ago, it cannot possibly still be valid! Most parsers can’t possible see this, even if theoretical possible as they wouldt need to render the page which gives enourmous overhead when scarping say a million webpages. I am pretty sure you eliminate 99% of scrapers this way.

  • http://www.open-source-editor.com Mattias Wirf

    Great, the more ways to fight spam the better. I also think about the none js browsing visitors, but that can’t be a high number, right?

  • qqrq

    Kim => IMHO worrying about users that don’t have JS enabled is NOT just old-fashioned. Remember about tools that disable JS, which user can install (i.e. as Firefox add-on). It’s not a bad idea to use this stuff – if you launch browser from admin account (everything else in WinXP is pain in the ass), you can still suffer from “evil” scripts. And what about work? Some of us have blocked scripts doing their jobs.

  • http://fedmich.com/life fedmich

    I prefer the js version, but if possible, I’ll just make an image to show the email.

    anyway, here’s one I made before and use,
    http://www.pastetool.com/hide_email/

    Thanks for sharing :)

  • http://wesam.ly Wesam Alalem

    great function, I was using something like ‘mail AT example DOT com’, but now I’ll use this.
    Thank you

  • http://www.steinhaug.no/ Kim Steinhaug

    Alright, I just got the perfect sollution to make everyone happy here. The noscript function should simply be something like:

    A simple switching of letters and other way around serverside, and voila a perfect sollution! To bad I dont have my own blog up, I could have made myself some bonus hits by adding this feature!

  • http://www.steinhaug.no/ Kim Steinhaug

    Nice, the code was removed, logic was

    noscript
    img src=”imagecreation.php?codedemail@here.com

    The email fed to the image cration script would then have some letter switching, simple as a=c, c=b,c=a and such would be enough – than other way around server side.

  • http://fedmich.com/life fedmich

    GD Creation of image adds CPU load on the server, which I don’t want to resort to as much as possible.

  • http://www.ahwd.co Aisha Henderson

    I love this. Awesome!

  • chris

    Kim,
    I’d love to see more of your script. I follow that you’re using php to generate an img (which i’ve never even thought to do). I get you have some script that switches letters, too, but if you’re generating an image with the email address, why do you need to switch the letters?
    Thanks!

  • Joshbedo

    Couldn’t somebody simply create a jQuery script using DOM manipulation looking for href:mailto links and getting all characters after until a double quote or single quote appears?

Supported By

Deals

Web Browsers Icon Set
Food Icon Set
Flat Icon Set

Flat Icon Set

100 icons