Top Commentator Fix Available

The Top Commentator plugin is a neat WordPress plugin since it allows a good way to reward frequent commentators on your site with a site-wide, followed, link. Unfortunately, there is a problem with it that allows a different visitor to your site to essentially hijack a link by a trust commentator. Because of this, I had previously set the links generated by this widget to nofollow until I could take the time to delve deeper in the the PHP and MySQL code behind this widget. I got around to doing this today and found that the fix to it should be quite simple.

The Fix

This may bore/confuse some of you non-programmer types but here’s what the problem was in the plugin. In a function called “ns_get_user_url” the URL for each person on the Top Commentator list is retrieved. The MySQL statement that delivers this information looks like this:

 

SELECT comment_author_url
FROM $wpdb->comments
WHERE comment_author = '".addslashes($user)."'
AND comment_author_url != 'http://'
$ns_options[filter_urls]
ORDER BY comment_date DESC LIMIT 1

 

The problem with this query was two fold. First of all, it allowed a visitor to switch their URL with every new comment. This allowed them to change their URL from one you approved of to one you did not. Secondly, it allowed a different visitor who used the same name to essentially hijack the Top Commentator spot with their own URL. Plus, it could even do this if the comment wasn’t approved or even sent to the Akismet filter!

To remedy this situation, I changed the code for the MySQL statement as follows:

 

SELECT comment_author_url
FROM $wpdb->comments
WHERE comment_author = '".addslashes($user)."'
AND comment_author_url != 'http://'
$ns_options[filter_urls]
AND comment_approved = '1'
ORDER BY comment_date ASC LIMIT 1

 

As you can see here, I simply added a check to only retrieve URL’s for approved comments and to get the URL for the first comment submitted rather than the last one. This should prevent unwanted gaming of the widget.

The Download

Here’s the download link for the updated plugin: Top Commentator Fix

To install it simply unzip the download file and FTP the file, show_top_commentators.php ,to your /[your website root directory name here]/wp-content/plugins/show_top_commentators folder, overwriting the current version of the plugin’s PHP file that’s already there.

If you run into any problems and have any questions about it, please let me know in a comment here.

Share This Post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • bloggingzoom

 

 

RSS feed | Trackback URI

6 Comments »

Comment by Houseboat Rentals
2008-05-04 19:59:34

I had just heard about the hijacking issue with the top commenter plug-in. So I stopped adding it to my new blogs (not that I get many comments anyway) But if all goes well with Vics contest I hope to finally learn how to get traffic to my blogs, henses getting more comments.

I will be trying your plug-in and let you know for sure if I have any issues.

Thanks

Denise

Comment by jfc
2008-05-05 11:02:31

Hi Denise,

Let me know if you run into any problems with it.

 
 
Comment by Link Building Bible
2008-05-05 13:13:24

I will be implementing this…. thanks for pointing out this fix… My blog isn’t big enough yet for people to even be attempting to hijack my top commenters…

Comment by jfc
2008-05-05 13:31:40

Hi Link Building,

The main thing that I was surprised to find out from this was that a post that got Akismet’ed could change the Top Commentator URL.

People go after newer and lower traffic blogs too, especially if they have PR. It’s all about getting that followed link, you know.

 
 
Comment by Chetan
2008-05-07 15:53:47

I saw this URL hijack happening in my blog and so wanted a fix for that! Commentators with more than 20 comments see their name linked to some other websites, its just odd.
Thanks for the fix.

Comment by jfc
2008-05-07 16:11:57

You’re welcome Chetan. I hope it helps.

 
 
Name (required)
E-mail (required - never shown publicly)
A Link To Your Site
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment. Comments with links are automatically moderated but are normally allowed after review. You may use anchored text in your signature link as long as your comment is meaningful and on topic.

 

Some graphics Copyright 2005 Riverdeep Interactive Learning Limited, and its licensors. All rights reserved
Some graphics Copyright 2005 Cosmi Corporation, and its licensors. All rights reserved.
All graphics are intended for viewing purposes only.

Directory of General Blogs Personal blogs Top Blogs Marketing SEO blogs blogoriffic.com Webfeed (RSS/ATOM/RDF) registered at http://www.feeds4all.com BRDTracker