I am trying to convert mailto: links to png images for thwarting spambots. I do have a solution working, but it doesn't appear that it would thwart any bot as the email is still there. My users use a custom built CMS system and design their own webpages online. I tell them not to include email addresses, but you know how people listen. Here is some sample code on the display page, after pulling $content from the database:
Code: Select all
$emailreg = "/<a href=\"mailto:([[:alnum:]_\.\-]+\@[[:alnum:]\.\-]+\.+[[:alnum:]\.\-]+)\">[[:alnum:]_\.\-]+\@[[:alnum:]\.\-]+\.+[[:alnum:]\.\-]+<\/a>/";
$emailrep = "<img src=\"/includes/texttoimage.php?text=$1\">";
$content = preg_replace($emailreg, $emailrep, $content);
This works great, the texttoimage.php file uses imagettftext and other things to generate the png. However, the source code still has the email address as an argument. A couple of thoughts were to use the texttoimage as a function so it never leaves the code, or to hash/obfuscate the email address, then reverse it before it is written, a la Facebook. The latter might be the easiest, but I'm not sure how to do it and reverse it in the texttoimage. Any thoughts? Thanks.