Spambot Defense Code

From: Date: Wed, 24 Jul 2002 05:15:03 +0000
Subject: Spambot Defense Code
Groups: php.general 
Request: Send a blank email to php-general+get-109249@lists.php.net to get a copy of this message
Worked on this a bit tonight, thought it might help someone out there! I looked at the bottomw of phpclasses.org at what they'd done to obfuscate their e-mail address using JavaScript. While theirs is much more complex, I couldn't figure a way to do it their way when you don't know the exact user@domain of people in your database. I thought this might do the trick, at least to some extent, by separating the user and domain in the source code and not put them together until the mailto: link is clicked. Sorry if something like this has been posted before - if so, here it is again! :) <script language="JavaScript"> <!-- <?php $email = "solja@gci.net"; //replace with e-mail addy from db $new_email = explode("@", $email); //separate into two sections based on the "@" print "function hide_me()\n"; print "{\n"; print "var usr= '$new_email[0]';\n"; //the user of user@domain print "var dom= '$new_email[1]';\n"; //the domain of user@domain print "window.location=\"mailto:\"+usr+\"@\"+dom;\n"; //print JS to recombine the parts print "}\n"; ?> //--!> </script> <a href="javascript:hide_me()">E-mail me</A>

« previous php.general (#109249) next »