1
snakes
module.textsanitizer.php hack for encrypting email addresses
  • 2005/6/22 14:47

  • snakes

  • Just popping in

  • Posts: 69

  • Since: 2004/8/8 0


Edit the file "class/module.textsanitizer.php"
Look for the function &makeClickable(&$text)
replace
$replacements = array("\1\2://\3" target="_blank">\2://\3", "\1http://www.\2.\3", "\1ftp.\2.\3", "\1\2@\3");

with
$replacements = array("\1\2://\3" target="_blank">\2://\3", "\1http://www.\2.\3", "\1ftp.\2.\3", "\1var id='\2';var host1='\3';var host2='';document.write(''+id+'@'+host1+'.'+host2+'');");


This should replace any email address in the text by a javascript code that generate the mailto tag.

2
McNaz
Re: module.textsanitizer.php hack for encrypting email addresses
  • 2005/6/22 14:56

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


Awsome hack and should definetly makes its way into the core.

even better (but only slightly):

$replacements = array("\1\2://\3" target="_blank">\2://\3", "\1http://www.\2.\3", "\1ftp.\2.\3", "\1var id='\2';var host1='\3';var host2='';document.write(''+id+'@'+host1+'.'+host2+'');");


if you want to be

$replacements = array("\1\2://\3" target="_blank">\2://\3", "\1http://www.\2.\3", "\1ftp.\2.\3", "\1var id='\2';var host1='\3';var host2='';document.write(''+id+'@'+host1+'.'+host2+'');");


Please note that the @ is & # 64;

3
JamesSAEP
Re: module.textsanitizer.php hack for encrypting email addresses
  • 2005/6/22 15:12

  • JamesSAEP

  • Just can't stay away

  • Posts: 732

  • Since: 2005/2/28


McNaz -

I'm not a programmer by any means... What it the difference between your two replacements?

4
McNaz
Re: module.textsanitizer.php hack for encrypting email addresses
  • 2005/6/22 15:19

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


Hi Jamescne.

Thinking about it, Snake probably did the same in his code.

The difference in mine was instead of using the @ character I used the ascii equivuilant of it which is & # 64. These are strung together in one word otherwise a browser would then interpret and display it as @, which is why my submitted code looks identical Snake's.

This would fool spiders even more.

My second example sneaks in a fake email address in a comment.

5
Mithrandir
Re: module.textsanitizer.php hack for encrypting email addresses

McNaz's has a little extra "salute" to the crawler.

Which I think I'll leave out, if you don't object

I also changed it to
6
jtessier72
Re: module.textsanitizer.php hack for encrypting email addresses
  • 2005/9/7 22:25

  • jtessier72

  • Just popping in

  • Posts: 3

  • Since: 2005/5/18


Trying to come up with something for the xoopscode emails which comes up a little later in module.textsanitizer.php

$replacements[] = '\1';


replace with:

$replacements[] = "text/javascript">var em='\1';document.write('mailto:'+em+'">'+em+'');";



Look good?

7
zimmi88
Re: module.textsanitizer.php hack for encrypting email addresses
  • 2005/9/7 22:37

  • zimmi88

  • Just popping in

  • Posts: 57

  • Since: 2005/3/9 1


hi. this sounds like a really good hack and would help in solving problems w/ crawlers and spammers. however, one question; is this hack compatible w/ 2.2, 2.0, or both? Thanks!

-zimmi88 =)
"Need coffee, keep away..."

8
snakes
Re: module.textsanitizer.php hack for encrypting email addresses
  • 2005/10/4 12:43

  • snakes

  • Just popping in

  • Posts: 69

  • Since: 2004/8/8 0


Hi there.
I didn't activate the "Notify me of new posts in this thread" so I forgot that I've sent this post...

I didn't try it for 2.2.x
Gonna have a look now...
...
...Wow!
It is already in the 2.2.2 package!
So you don't need to change anything.

9
snakes
ERRATUM
  • 2005/12/29 9:14

  • snakes

  • Just popping in

  • Posts: 69

  • Since: 2004/8/8 0


There was an error in the replacement.
It was:
$replacements = array("\1\2://\3" target="_blank">\2://\3", "\1http://www.\2.\3", "\1ftp.\2.\3", "\1var id='\2';var host1='\3';var host2='';document.write(''+id+'@'+host1+'.'+host2+'');");


But should be:
$replacements = array("\1\2://\3" target="_blank">\2://\3", "\1http://www.\2.\3", "\1ftp.\2.\3", "\1var id='\2';var host1='\3';document.write(''+id+'@'+host1+'');");


In the first code var host2='' this id+'@'+host1+'.'+host2 would always have a '.' (dot) at the end...

If you keep the first replacement then the search pattern array should be:
$patterns = array("/(^|[^]_a-z0-9-="'/])([a-z]+?)://([^rn"()'<>]+)/i",
        "
/(^|[^]_a-z0-9-="'/])www.([a-z0-9-]+).([^rn"()'<>]+)/i",
        "/(^|[^]_a-z0-9-="'
/])ftp.([a-z0-9-]+).([^rn"()'<>]+)/i",
        
"/(^|[^]_a-z0-9-="'/:.])([a-z0-9-_.]+?)@([a-z0-9-_.]+?).([^rn"()'<>[]]+)/i");


instead of:
$patterns = array("/(^|[^]_a-z0-9-="'/])([a-z]+?)://([^
                            rn"()'
<>]+)/i",
        "
/(^|[^]_a-z0-9-="'/])www.([a-z0-9-]+).([^
                            rn"
()'<>]+)/i",
        "/(^|[^]_a-z0-9-="'
/])ftp.([a-z0-9-]+).([^
                            
rn"()'<>]+)/i",
        
"/(^|[^]_a-z0-9-="'/:.])([a-z0-9-_.]+?)@([^rn"()'<>[]]+)/i");


For some XOOPS release, this should be(which I found better):
$patterns = array(
        
"/(^|[^]_a-z0-9-="'/])([a-z]+?)://([^, rn"()'<>]+)/i",
        "
/(^|[^]_a-z0-9-="'/])www.([a-z0-9-]+).([^, rn"()'<>]+)/i",
        "/(^|[^]_a-z0-9-="'
/])ftp.([a-z0-9-]+).([^, rn"()'<>]+)/i",
        
"/(^|[^]_a-z0-9-="'/:.])([a-z0-9-_.]+?)@([a-z0-9-_.]+?).([^, rn"()'<>[]]+)/i"
        );


instead of:
$patterns = array("/(^|[^]_a-z0-9-="'/])([a-z]+?)://([^, rn"()'<>]+)/i", "/(^|[^]_a-z0-9-="'/])www.([a-z0-9-]+).([^, rn"()'<>]+)/i", "/(^|[^]_a-z0-9-="'/])ftp.([a-z0-9-]+).([^, rn"()'<>]+)/i""/(^|[^]_a-z0-9-="'/:.])([a-z0-9-_.]+?)@([^, rn"()'<>[]]+)/i");


By the way, I've noticed that in 2.2.3 the pattenrs array have been changed and the old one was in comment. For me the new array doesn't work well, it sometimes take texts after the mail or URL into account... Uncommenting the old, commenting the news works great.

10
Tobias
Re: ERRATUM
  • 2006/1/6 15:10

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Thanks a bunch, snakes, no more dots and other stuff behind the email addresses

Login

Who's Online

337 user(s) are online (207 user(s) are browsing Support Forums)


Members: 0


Guests: 337


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits