Anti-spam munge of [MAIL] RT

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
powerpenguin
Posts: 4
Joined: Fri 27. Jan 2006, 16:48
Location: Hamburg / Amsterdam

Anti-spam munge of [MAIL] RT

Post by powerpenguin »

Hi there,

since I put my site online, I have been receiving an increasing amount of spam on its contact address. Since I think it is good practice to do everything possible to fight spam, I hacked in a small enhancement in phpwcms ( 1.2.8 ) that implements the solution (3) given on http://www.spamspan.com in the MAIL replacement tag.

What I did:
  1. download http://www.spamspan.com/releases/spamspan-latest.zip and unzip spamspan.js into phpwcms_template/inc_js/
  2. in index.php find

    Code: Select all

    $content['page_start'] .= '  <script src="'.TEMPLATE_PATH.'inc_js/frontend.js" type="text/javascript"></script>'.LF;
    
    (around line 107) and under it add the line

    Code: Select all

    $content['page_start'] .= '  <script src="'.TEMPLATE_PATH.'inc_js/spamspan.js" type="text/javascript"></script>'.LF;
  3. in include/inc_front/front.func.inc.php find the line where $search[23] is defined and change to (includes commented out originals)

    Code: Select all

    // this pharses out an E-Mail Link without subject (by Florian, 21-11-2003)
    // updated by Powerpenguin (2006.12.05) to  be more spambot-safe (acc. to http://www.spamspan.com)
    // $search[23]     = '/\[MAIL (.*?)\](.*?)\[\/MAIL\]/i';
    // $replace[23]    = '<a href="mailto:$1">$2</a>';
    // splits MAIL RT in 1.user 2.domainname 3.domainextension 4.alias
    // (4 is not used a.t.m.)
    $search[23]     = '/\[MAIL (.*?)@(.*?)\.(.*?)\](.*?)\[\/MAIL\]/i';
    $replace[23]    = '<span class="spamspan"><span class="u">$1</span> [at] <span class="d">$2 [dot] $3</span></span>';
Now your RT [MAIL user@domain.com]alias@not.used[/MAIL] should expand to html source that is much less vulnerable to being harvested by spam-bots.
Cheers,

Jeroen
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

hi powerpenguin

you are new to phpwcms?

there are a lot ways, to do this easier without the "bad" sourcecode hacking.
the JS include can put in the headsection of the template, no need to change the index.php

front.func.inc.php is critical to change (keep in mind further updates)

I would suggest, that you use the frontend_render "plug in interface" and write your own replacement tag for that!

take a look here: http://phpwcms.de/forum/viewtopic.php?t ... am&start=0
(there is another similar Tag with JS Solution)

try to keep the core code untouched and use the frontend_render folder for an own Tag/Solution.

That#s my opinion :-)

greetings
marcus
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Post by flip-flop »

Hi powerpenguin,

there we have an other solution, a combination of PHP and JS. No hack, a simple rt.
http://www.phpwcms.de/forum/viewtopic.php?t=11339

Regards Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
powerpenguin
Posts: 4
Joined: Fri 27. Jan 2006, 16:48
Location: Hamburg / Amsterdam

Post by powerpenguin »

Sorry for getting back late, apparently forgot to turn on email warning for replies.

@marcus, indeed I'm quite new to it, thanks for your explanation...

@flip-flop,
I read the docu, but indeed didn't double-check for its incompleteness :oops: , so I missed that enhancement. I will try it.

Thanks :!:
Cheers,

Jeroen
Post Reply