It is very easy in PHP to make a low security email address code-or-decode obfuscator:
strrev(str_rot13(email_address));
On the Javascript side (used to access HTML form elements), however, there don't seem to be any similar built-in functions.
I know this is a PHP forum, but does anyone know an easy method both in PHP and Javascript for simple obfuscation to avoid spammer bots? Perhaps flipping string bits or something?
Simple, emphasize SIMPLE, PHP/Javascript email addr hiding
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
You could always build them (the javascript functions) yourself.
Here are some common ways of munging email addresses:
1. Not giving the email address at all. Rather, provide a contact form that people can use.
2. Change user@domain.com to user AT domain DOT com
3. Change user@domain.com to user@domain.nospam-removethis.com
4. Put a bunch of hexadeciimal things in JavaScript and have that translate it out (Smarty has an implementation of this)
Here are some common ways of munging email addresses:
1. Not giving the email address at all. Rather, provide a contact form that people can use.
2. Change user@domain.com to user AT domain DOT com
3. Change user@domain.com to user@domain.nospam-removethis.com
4. Put a bunch of hexadeciimal things in JavaScript and have that translate it out (Smarty has an implementation of this)
On the Javascript side, I modified (sloppier but much more compact) some code I found:
The Javascript deCode function will work well for manipulating HTML FORM fields.
Now I just have to translate the enCode function into PHP.
Code: Select all
<script language="Javascript">
function enCode(addr){ var kode, gunk="", L=addr.length;
for (var x=0;x<L;x++) { kode = addr.charCodeAt(x)+L; gunk+=kode; if(x<L-1) gunk+="|"; } return gunk;
}
function deCode(gunk){ var kode,oneC, kStr=new String(gunk), kArray=kStr.split('|'), L=kArray.length, orig="";
for (var x=0;x<L;x++) { kode=kArray[x]; oneC=String.fromCharCode(kode-L); orig+=oneC; } return orig;
}
</script>Now I just have to translate the enCode function into PHP.
Code: Select all
print("<script type='javascript'><!--\n".
"var string = ''\n");
$string = "hello";
$string = explode($string);
foreach ($string as $letter) {
print("string += '$letter';\n");
}
print("document.write(string); // or whatever".
"//--></script>");Code: Select all
var string = '';
string += 'h';
string += 'e';
string += 'l';
//...