ramesh
ramesh

Reputation: 21

url obfuscator in php

I need a url obfuscator that a spider should not extract my links like safe_mailto in codeiginitor... is it possible using PHP if so please give an example.

Upvotes: 2

Views: 1903

Answers (2)

aularon
aularon

Reputation: 11110

Construct a script tag, that will concatenate the email out of smaller String.fromCharCode calls, maybe with a combination of html entities as @Dominic suggested, you can make it more complex with various approaches. The point is to stop the majority of email grabbers from finding it out.

Would it stop them? Not totally. Spam bots are becoming smarter day after day, and it will take somebody like 5 mins to emulate your algorithm to reconstruct emails out of your output. As mentioned by @ircmaxell: "Security through obscurity is no security at all".

Any good approach?: Yes! Put all emails in a database table, with ids (in case they weren't already stored in such manner), the user will click something like reveal.php?email=1564, that page will display a recaptcha, or any other good captcha, and if valid, it will show them the email.

Upvotes: 2

Dominic Rodger
Dominic Rodger

Reputation: 99801

 $link = 'mailto:[email protected]';
 $obfuscatedLink = "";
 for ($i=0; $i<strlen($link); $i++){
     $obfuscatedLink .= "&#" . ord($link[$i]) . ";";
 }

As ircmaxell commented, this is a very primitive obfuscation, and really won't deter many spammers.

Upvotes: 1

Related Questions