Skip to content

Instantly share code, notes, and snippets.

@clivewalkden
Created May 3, 2012 07:36
Show Gist options
  • Save clivewalkden/2584040 to your computer and use it in GitHub Desktop.
Save clivewalkden/2584040 to your computer and use it in GitHub Desktop.
method of hiding email addresses from harvesters
<?php
function utf_char_to_number($char)
{
$i = 0;
$number = '';
while (isset($char{$i}))
{
$number .= '&#'.ord($char{$i}).';';
$i++;
}
return $number;
}
function utf_char_to_hex($char)
{
$i = 0;
$number = '';
while (isset($char{$i}))
{
$number .= '%'.bin2hex($char{$i});
$i++;
}
return $number;
}
$email_post = utf_char_to_hex($email);
$link_post = (empty($link)) ? utf_char_to_number($email) : utf_char_to_number($link);
echo 'Normal Style:<br />'.PHP_EOL.htmlentities('<a href="mailto:'.$email_post.'">'.$link_post.'</a>');
echo '<br /><br />';
echo 'Javascript Method:<br />'.PHP_EOL.htmlentities('<script language="JavaScript">document.write(\'<a hre\'+\'f="ma\'+\'ilto\'+\':\'+\''.$email_post.'">'.$link_post.'</a>\');</script>');
echo '<br /><br />';
echo 'Wiki Style:<br />'.PHP_EOL.htmlentities('[mailto:'.$email_post.' '.$link_post.']');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment