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.
-
10how about not obfuscating the question first? – Gordon Sep 07 '10 at 12:21
-
5I must ask, why do you want to do so? Are you trying to make it more secure? Security through obscurity is no security at all... – ircmaxell Sep 07 '10 at 12:21
-
1possible duplicate of [Best way to obfuscate an e-mail address on a website?](http://stackoverflow.com/questions/748780/best-way-to-obfuscate-an-e-mail-address-on-a-website) – Gordon Sep 07 '10 at 12:32
-
@ircmaxell Unless you mean to say that obfuscating email addresses does nothing to prevent them being harvested, your comment is misplaced. – slikts Sep 07 '10 at 12:35
-
2I like how OP says 'url' multiple times instead of 'email' yet people figure it out correctly based on 'safe_mailto'. – BoltClock Sep 07 '10 at 12:43
2 Answers
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.

- 11,042
- 3
- 36
- 41
$link = 'mailto:example@example.com';
$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.

- 97,747
- 36
- 197
- 212