Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Would this stop spambots? 1

Status
Not open for further replies.

Sensibilium

Programmer
Apr 6, 2000
310
GB
I've been looking at ways of hiding email addresses within web pages from spambots, and so far I hav found an ASP script that converts email addresses to ASCII text, so I decided to create a similar function for PHP:

Code:
<?PHP
function ASCIIcode($input)
{
$output = '';
for ($i=0;$i<strlen($input);$i++)
 {
  $output .= '&#' . ord(substr($input, $i, 1)) . ';';
 }
 return $output;
}
?>

Calling could be done in many ways, but here's my preferred method:

Code:
echo '<P><A href="'.ASCIIcode('mailto:me@terry.com').'">Email Me!</A>';

Whether this works at stopping the spambots from harvesting the email addresses I really don't know, but theoretically it should...

Anyone think this may not work as I hope?

TIA

Ahdkaw
 
First, if you're going to use this method of obfuscation, I recommend you use the PHP function htmlentities().

Second, I really doubt if this method of obfuscation will even slow down the spambots.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
It works on a few but not all. The best luck I have seen (until the spambots get wiser) is to break up the email address into several lines with javascript...

Code:
<script language="JavaScript" type="text/javascript">
//<!--
   document.write ('<a href="mailto:')
   document.write ('me'+'@'+'a')
   document.write ('ol'+'.'+'com">')
   document.write ('me'+'@'+'ao')
   document.write ('l'+'.'+'com'+'</a>')
//-->
</script>

The line breaks and extra characters ('document.write', etc.) give a decent obstacle. To automate this script generation with PHP, you can pass variable email addresses through substr() to chop up the javascript.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top