Jeremy Scharlack's Blog
(not | yet) another blog
Tech
Archives

« On the candidates | Main | Changing URLs in comment body »

February 04, 2004

New Comments

Due to the Comment Spam I had been getting I decided to edit my comment templates again.

It seems comment spammerrs aren’t spamming me to get my attention, but to increase their google ranking with a link. So I am changing all commenter’s urls to redirection links using a little perl script I wrote located at go.cgi:

#!/usr/bin/perl
use CGI ':standard';
$link = param('link');
if ( !$link ) {
        $referer = referer();
        if (!$referer) { $referer = "javascript:history.go(-1)"; }
        print "Content-Type:text/html\n\n";
        print "No URL given for this user<br>";
        print qq|<a href="$referer"*gt;<-- Go Back|;
}
else {

        if ( $link =~ m/http/ || $link =~ m/mailto/ ) {}
        else { $link = "http://" . $link; }

        print "Location:$link\n\n";
}

The script is called as go.cgi?link=www.wherever.com. The very last line redirects someone $link, in this case www.wherever.com. The other stuff includes checking if there is an http:// in the name and adding one if there isn’t. It also checks for a mailto and it uses that if it is present. It also will print up a page saying there is no link if none is specified.

I modified the comment parts of my individual archive template to:

<span class="comments-post">
 Posted by: <$MTCommentAuthorLink spam_protect="1" show_url="0" $>
 from <a href="http://blog.scharlack.com/go.cgi?link=<$MTCommentURL$>">here</a>
 at <$MTCommentDate$> | 
 <a href="<$MTEntryPermalink$>#<$MTCommentID pad="1"$>">link</a>
</span>

This creates two links, one for the e-mail and the other for the url. I couldn’t find a better way to do it since the <$MTCommentAuthorLink$> tag creates a whole link with both tags and a name.

This also resolves another issue of mine: it stops the url links in my comments from opening another window. Just a little thing I never liked.

Posted by Jeremy at 01:47 AM | Link | TrackBack (0)


Comments

A link test.

Posted by: Jeremy from here at February 4, 2004 02:07 AM | link
Post a comment









Remember personal info?






 

Archives

Recent Entries

Links




Powered by
Movable Type 2.63