Hi.
Uh... I sincerely apologize if this is the wrong board - I tried and tried and tried and tried and....ok you get it.... to find a code snippet that 'encodes' and 'decrypts' email addresses.
I would have thought in this day and age you could find any piece of code in about 12 seconds........but not so.
The idea is that you first encode an email address that you will use in a mailer script from a contact form. You store the encoded string so that bots can't easily pickup your email addresss. Then in the mailer script you would call this piece of code to 'decrypt' the characters into the email addresss, so that the address is only present in memory.
Sorry if there's something famous out there that I don't know about.... but I looked for a 1/2 hour yesterday with no luck
Codeless in Columbus
email address encoder needed
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
The easiest is to encode to HTML entities.
Code: Select all
function encode_address($addr)
{
$output = "";
for ($i = 0; $i < strlen($addr); $i++) {
$output .= sprintf("&#x%X;", ord($addr{$i}));
}
return $output;
}
$address = "foo@bar.com";
echo encode_address($address);uh.. where's the 'Undo Button'
Hi,
Now exactly how do I 'decrypt' or 'decode' this puppy?
Once I store the value of the varialbe $output - on the form, the php code will need to 'decode' or 'decrypt' this string back into the email addresss
???????????????????????
Codeless in Columbus
Now exactly how do I 'decrypt' or 'decode' this puppy?
Once I store the value of the varialbe $output - on the form, the php code will need to 'decode' or 'decrypt' this string back into the email addresss
???????????????????????
Codeless in Columbus
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: uh.. where's the 'Undo Button'
Did you actually run this in your browser? That's just HTML so the browser treats it as "foo@bar.tld" just the same as the string form. So if you echo it into a form field or something, when the form is submitted you'll get "foo@bar.tld" even if the markup is all HEX.VmusicV wrote:Hi,
Now exactly how do I 'decrypt' or 'decode' this puppy?
Once I store the value of the varialbe $output - on the form, the php code will need to 'decode' or 'decrypt' this string back into the email addresss
???????????????????????
Codeless in Columbus
But in any case, this will decode if you still need to know:
Code: Select all
function decode_addr($addr)
{
return preg_replace('/&#x([A-F0-9]{2});/e', ' chr(0x$1); ', $addr);
}Thanks!!!
Hi,
Thank you so much. So what I will do is first figure out the encoded value for the string, and I will have that in my output html - so any bot can't directly see the email address. Then in the mailer script - I'll pass that string to the decode function to return back the actual email address.
Thanks So Much
Vmusic
Thank you so much. So what I will do is first figure out the encoded value for the string, and I will have that in my output html - so any bot can't directly see the email address. Then in the mailer script - I'll pass that string to the decode function to return back the actual email address.
Thanks So Much
Vmusic
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Thanks!!!
You should never need to decode it. The browser will do that. Try it.VmusicV wrote:Hi,
Thank you so much. So what I will do is first figure out the encoded value for the string, and I will have that in my output html - so any bot can't directly see the email address. Then in the mailer script - I'll pass that string to the decode function to return back the actual email address.
Thanks So Much
Vmusic