Hide registrations spam

Submitted by CyberAlien, Mar 2007.
There are many spam bots that register on your forum with link to some junk website in their profile. Purpose of those bots is to increase search engine position of website they are spamming.

These users are completely harmless in terms of security, but linking to spam websites might decrease your website's search engine rankings, and you do not want your visitors to see those spam links, so its always a good idea to hide those links.

There are several methods to do it:

1. Hide homepage link

Simpliest method is to hide homepage link in user's profiles. But we don't want to hide everyone's links, just spammer's links. All registration spammers have 0 posts.

Open memberlist.php, find this:
Code:
  1.        $www_img = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';  
  2.        $www = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';  
and replace it with this:
Code:
  1.        $www_img = ( $row['user_website'] && $row['user_posts'] > 0 ) ? '<a href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';  
  2.        $www = ( $row['user_website'] && $row['user_posts'] > 0 ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';  
then open includes/usercp_viewprofile.php, find this:
Code:
  1. $www_img = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '&nbsp;';  
  2. $www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : '&nbsp;';  
and replace with this:
Code:
  1. $www_img = ( $profiledata['user_website'] && $profiledata['user_posts'] > 0 ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '&nbsp;';  
  2. $www = ( $profiledata['user_website'] && $profiledata['user_posts'] > 0 ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : '&nbsp;';  
That's all.

2. Hide 0 posters from users list

Another method is to hide all users with 0 posts from users list.

Open memberlist.php, find this:
Code:
  1.    FROM " . USERS_TABLE . "  
  2.    WHERE user_id <> " . ANONYMOUS . "  
  3.    ORDER BY $order_by";  
and replace with this:
Code:
  1.    FROM " . USERS_TABLE . "  
  2.    WHERE user_id <> " . ANONYMOUS . " AND user_posts > 0  
  3.    ORDER BY $order_by";  
then find this:
Code:
  1.    $sql = "SELECT count(*) AS total  
  2.        FROM " . USERS_TABLE . "  
  3.        WHERE user_id <> " . ANONYMOUS;  
and replace with this:
Code:
  1.    $sql = "SELECT count(*) AS total  
  2.        FROM " . USERS_TABLE . "  
  3.        WHERE user_id <> " . ANONYMOUS . " AND user_posts > 0";  
That's all. If you have applied both methods then user profiles and member list will be clear of spammers.

Don't worry about extra space spammers take in database, its nothing compared to size of other data in your forum database, so I think its not worth the effort to manually delete those spammers and hiding them is a good simple solution.

Share this tutorial

If you want to show this tutorial to someone else please use following code to link to this tutorial:
HTML Link:
Forum BBCode:
Content of this tutorial may not be published anywhere else without author's permission. Please link to this page instead.