Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Plugin Requested | Encode Email Addresses

Quote Reply
Plugin Requested | Encode Email Addresses
Heya all,

I'm looking for a plugin (and will gladly pay for it! Wink ) for both GForum and LinksSQL that effectively encodes a fields like this:

http://www.wbwip.com/wbw/emailencoder.html

Would be good if it was possible to select the fields you want encoded in the plugin, it will ususally be email address fields, and simply return the Character Entities when the page is built instead of the actual address.

I'm declaring war on spambots that harvest my site for addresses and then load my GMail application with all their junk.

Any takers? Smile

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Plugin Requested | Encode Email Addresses In reply to
You could probably do it with a global;

<%global_name($Contact_Email)%>

Code:
sub {

my $in = $_[0];
my $strings = q|
a~097
b~098
c~099
d~100
e~101
f~102
g~103
h~104
i~105
j~106
k~107
l~108
m~109
n~110
o~111
p~112
q~113
r~114
s~115
t~116
u~117
v~118
w~119
x~120
y~121
z~122
1~049
2~050
3~051
4~052
5~053
6~054
7~055
8~056
9~057
0~048
&~038
~032
_~095
-~045
@~064
.~046
|;

my $back;
my @address = split //, $in; # cut the email address up into each charachter...
my @strings = split /\n/, $strings;

foreach (@address) {

my $next;

foreach my $s (@strings) {

$s =~ s/\s$//g;

next if $next == 1;

my ($char,$equiv) = split /~/, $s; # get the charachter, and its numerical equiv

if ($char eq $_) {
$char =~ s/\Q$char/$equiv/i;
$char = '&#' . $char . ';';
$back .= $char; # add the new replacement to $back
$next = 1;
}

}

}

return $back;

}

I just gave it a quick test on my site, and it seems to work ok :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Jun 26, 2004, 5:40 AM
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Andy,

Thanks a lot. It's getting there.... Seems like we have to add the codes for all upper case letters as well though. As it is it just throws them away. Smile

I also found a reply to this previous post. Not sure how to call this global, but it looks like a neat solution if that's all that's needed to make it work.

http://www.gossamer-threads.com/...i?post=265822#265822

Safe swoops
Sangiro

Last edited by:

sangiro: Jun 26, 2004, 6:26 AM
Quote Reply
Re: [sangiro] Plugin Requested | Encode Email Addresses In reply to
Mmm.. it shouldn't do Unsure (should just replace everything in lowercase).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Nope, it definately changed:

me_AT_dropzone_DOT_com

to:

me__dropzone__com

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Plugin Requested | Encode Email Addresses In reply to
Should be a simple fix though ;)

$in = $_[0];

...to

$in = lc($_[0]);

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Thanks! That should work for email addresses. It forces everything to small letters. Would be a problem if you decided to encode any other field, for example signatures in the forum which may hold text and an email address.

Will this also encode characters like: ?

Safe swoops
Sangiro

Last edited by:

sangiro: Jun 26, 2004, 7:34 AM
Quote Reply
Re: [sangiro] Plugin Requested | Encode Email Addresses In reply to
Quote:
Will this also encode characters like: ?

Afraid not.

Quote:
Would be a problem if you decided to encode any other field, for example signatures in the forum which may hold text and an email address.

Yeah, I guess the only way to get all the charachters changed over, would be to use something like HTML::Entity (if we could get it to work Frown), so similar.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [sangiro] Plugin Requested | Encode Email Addresses In reply to
I'll second that, that is a plug in we would gladly pay for.
Mike H

><((((>`.`..`...>(((>
.`.><((((>`..`..`...><((((>

http://www.bigfishtackle.com/...n/gforum/gforum.cgi?
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Andy,

I've added some upper case and special characters to your global. It's still not all of them but includes most except the "really weird" ones.

Would still like to see the other option in action. Smile

Code:
sub {

my $in = $_[0];
my $strings = q|
~032
&~038
+~043
-~045
.~046
0~048
1~049
2~050
3~051
4~052
5~053
6~054
7~055
8~056
9~057
:~058
;~059
@~064
A~065
B~066
C~067
D~068
E~069
F~070
G~071
H~072
I~073
J~074
K~075
L~076
M~077
N~078
O~079
P~080
Q~081
R~082
S~083
T~084
U~085
V~086
W~087
X~088
Y~089
Z~090
^~094
_~095
a~097
b~098
c~099
d~100
e~101
f~102
g~103
h~104
i~105
j~106
k~107
l~108
m~109
n~110
o~111
p~112
q~113
r~114
s~115
t~116
u~117
v~118
w~119
x~120
y~121
z~122
?~127
~130
~132
~138
~139
~142
~145
~146
~147
~148
~149
~150
~151
~152
~154
~155
~158
~159
~160
~161
~168
~175
~176
~180
~183
~192
~193
~194
~195
~196
~197
~198
~199
~200
~201
?~202
~203
~204
~205
~206
~207
~208
~209
~210
~211
~212
~213
~214
~215
~216
~217
~218
~219
~220
~221
~222
~223
~224
~225
~226
~227
~228
~229
~230
~231
~232
~233
~234
~235
~236
~237
~238
~239
~240
~241
~242
~243
~244
~245
~246
~247
~248
~249
~250
~251
~252
~253
~254
~255
|;

my $back;
my @address = split //, $in; # cut the email address up into each charachter...
my @strings = split /\n/, $strings;

foreach (@address) {

my $next;

foreach my $s (@strings) {

$s =~ s/\s$//g;

next if $next == 1;

my ($char,$equiv) = split /~/, $s; # get the charachter, and its numerical equiv

if ($char eq $_) {
$char =~ s/\Q$char/$equiv/i;
$char = '&#' . $char . ';';
$back .= $char; # add the new replacement to $back
$next = 1;
}

}

}

return \$back;

}

Safe swoops
Sangiro

Last edited by:

sangiro: Jun 26, 2004, 2:49 PM
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Hello Andy,

I test your Global.
I use the code on your site...

But, I have a problem.

It does not code the email correctly.

For example for name@serveur.com

It gives:
n%20;a%20;m%20;e%20;@s%20;e%20;r%20;v%20;e%20;u%20;r%20;.%20;c%20;o%20;m%20;

You have an idea ?

Thank you.

Mick
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
Are you using the code from the post just above your's?

It should change charachters to;

&#100

(with the 100 being the equivelant code).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Thank you Andy.

I use the code in this page.
http://www.sqlwidgets.com/...ncryption/index.html

An idea?

Mick
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
That should work. Can you paste the exact HTML output?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Hello Andy

I copied code but I always have the problem.

I do not understand.

Mick
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
I just want to see the whole bit of HTML code thats outputted Wink (for the email address)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
Mick,

I'm using the code just above (my last post) on several places, in both GForm and LinksSQL on my site and it works great. As Andy, says... you may want to show us the full global you're using and also all the output. Smile

Safe swoops
Sangiro
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Hello,

Thank you for your answer.

Here the code which I use.

<%encrypt_mails%>
-------------
sub {

my $in = $_[0];
my $strings = q|
a~097
b~098
c~099
d~100
e~101
f~102
g~103
h~104
i~105
j~106
k~107
l~108
m~109
n~110
o~111
p~112
q~113
r~114
s~115
t~116
u~117
v~118
w~119
x~120
y~121
z~122
1~049
2~050
3~051
4~052
5~053
6~054
7~055
8~056
9~057
0~048
&~038
~032
_~095
-~045
@~064
.~046
|;

my $back;
my @address = split //, $in; # cut the email address up into each charachter...
my @strings = split /\n/, $strings;

foreach (@address) {

my $next;

foreach my $s (@strings) {

next if $next == 1;

my ($char,$equiv) = split /~/, $s; # get the charachter, and its numerical equiv

if ($char eq $_) {
$char =~ s/\Q$char/$equiv/i;
$char = '&#' . $char . ';';
$back .= $char; # add the new replacement to $back
$next = 1;
}

}

}

return $back;

}
-------------

It gives the result for : mick@serveur.com

m ;i ;c ;k ;@ ;s ;e ;r ;v ;e ;u ;r ;. ;f ;r ;

<a href="mailto:&#109 ;&#105 ;&#099 ;&#107 ;&#064 ;&#115 ;&#101 ;&#114 ;&#118 ;&#101 ;&#117 ;&#114 ;&#046 ;&#102 ;&#114 ;">

You have an idea.

I do not manage to find my error.

Thank you for your assistance.

Mick
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
Ah, I think I see the problem. Try changing;

Code:
if ($char eq $_) {
$equiv =~ s|\s+$||g;
$char =~ s/\Q$char/$equiv/i;
$char = '&#' . $char . ';';
$back .= $char;
$next = 1;
}

Does that work now?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Oct 23, 2004, 2:53 AM
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Thank you Andy,

I modified the code.

But, it gives me an error message.

Unable to compile 'encrypt_mails': syntax error at (eval 81) line 59, near

--------------------
sub {
my $in = $_[0];
my $strings = q|
a~097
b~098
c~099
d~100
e~101
f~102
g~103
h~104
i~105
j~106
k~107
l~108
m~109
n~110
o~111
p~112
q~113
r~114
s~115
t~116
u~117
v~118
w~119
x~120
y~121
z~122
1~049
2~050
3~051
4~052
5~053
6~054
7~055
8~056
9~057
0~048
&~038
~032
_~095
-~045
@~064
.~046
|;
my $back;
my @address = split //, $in; # cut the email address up into each charachter...
my @strings = split /\n/, $strings;
foreach (@address) {
my $next;
foreach my $s (@strings) {
next if $next == 1;
my ($char,$equiv) = split /~/, $s; # get the charachter, and its numerical equiv
if ($char eq $_) {
$equiv =~ s|\s+$||g;
$char =~ s/\Q$char/$equiv/i;
$char = '&#' . $char . ';'
$back .= $char;
$next = 1;
}
}
}
return $back;
}
--------------------------

You have an idea?

Mick
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
Sorry, the following line;

Code:
$char = '&#' . $char . ';'

..should be;

Code:
$char = '&#' . $char . ';';

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Plugin Requested | Encode Email Addresses In reply to
Thank you Andy,

The code is perfect. Smile

Mick
Quote Reply
Re: [mick31] Plugin Requested | Encode Email Addresses In reply to
Great Angelic

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!