Skip to content

Instantly share code, notes, and snippets.

@jasonmcleod
Created August 3, 2010 19:01
Show Gist options
  • Save jasonmcleod/506926 to your computer and use it in GitHub Desktop.
Save jasonmcleod/506926 to your computer and use it in GitHub Desktop.
/* Not sure if this has any effect against email scraping bots but it's an idea.
It just outputs the string as an array of character codes, then restores it
real characters after the page loads. With javascript disabled we fail. :( */
// PHP function ///////////////////////////////////
function mask($str) {
$mask = "";
for($c=0;$c<strlen($str);$c++) {
$mask .= "" . ord($str[$c]) . ",";
}
return "<span class='mask'>" . $mask . "</span>";
}
// end of PHP function ////////////////////////////
// jQuery function ////////////////////////////////
$(".mask").each(function() {
c = $(this).text().split(",");
v="";
for(l in c) {
v+=(String.fromCharCode(c[l]));
}
$(this).html(v);
});
// end of jQuery function /////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment