Jump to content

Recommended Posts

Posted

I have a template that list emails. I'm hiding emails with javascript (I could use Soma's EmailObfuscator), but javascript is no longer sufficient since bots execute javascript. I was thinking about captcha solution so that before the page is shown human "presence" is required. How could I do that? What are your solutions?

Matjaž

Posted

Bots are not (yet) clicking, so I ended up using this function, found somewhere on the net, modifed to my needs.

function hide_email($email) {
	$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
	$key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.mt_rand(1,999999999).mt_rand(1,999999);
	for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
	$script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";';
	$script.= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
	$script.= 'document.getElementById("'.$id.'").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>";';
	return "<span id='$id' onclick='$script'>[show email]</span>";
}

Someone with better programming skills might do better job (jquery?)... Google captcha could be alternative.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...