PHP Clever mailto
This piece of code makes an attempt to hide email addresses from spam harvesters.
The PHP generates some client-side JavaScript. A bot searching for email addresses will hopefully not
recognise the mailto link since it isn't visible in the source. This is adapted from some code written by Dr. Bob,
the Delphi guru
<?
function ShowEmail($User, $Domain, $Text="")
{
print("<script language=\"JavaScript\">\n");
print("user=\"" . $User . "\";\n");
print("site=\"" . $Domain . "\";\n");
print("document.write('<a href=\\\"mailto:' + user + '@' + site + '\\\">');\n");
if ($Text == "")
{
print("document.write(user + '@' + site + '</a>');\n");
}
else
{
print("document.write('" . $Text . "' + '</a>');\n");
}
print("</script>\n");
}
?>
|