Stop Forum Spam

An online diary of people and events on my mind.

Stop Forum Spam

Postby mxsquid » 04 Feb 2009, 13:31

http://www.stopforumspam.com/

http://www.botscout.com/code.htm

http://www.stopforumspam.com/search?q=

http://www.projecthoneypot.org/index.php

Lithium Studios EXreaction for phpBB2 currently

Spambot Search Tool: SBST

http://temerc.com/Check_Spammers/

http://support.it-mate.co.uk/?mode=Prod ... searchtool

http://www.ipaddresslocation.org/


Find "real IP address in PHP"

Roshan Blog



Code: Select all
function getRealIpAddr()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}
mxsquid
Site Admin
 
Posts: 543
Joined: 22 Mar 2008, 18:52

Re: Stop Forum Spam

Postby mxsquid » 22 Mar 2009, 09:19

Stop Forum Spam (SFS) Integration

A simple tool to identify and dynamically prevent phpBB3 forum registration by known spammers via e-mail, username, IP address. Thanks to Alex Doolittle for the original idea with minor code modifications by me for Version 1.02.

http://www.stopforumspam.com/

http://www.alexdoolittle.com/


Code: Select all
################################################################################
##
## Mod Title:        SFS Anti-Spam Registration for phpBB3
## Mod Author:       Alex Doolittle, info@alexdoolittle.com
##                   Mike S, mx_s@lycos.com
##
## Mod Description:    This MOD adds an IP, email, and username check when
##            registering using the stopforumspam.com API blacklist
##            and prevents registration upon finding a match.
##
## Mod Version:        1.0.2
##
##
## Compatibility:    3.0.0, 3.0.3, 3.0.4
##   
##
## Installation Level:    Easy
## Installation Time:     5 Minutes
##
## Files To Edit:    4
##
##            includes/ucp/ucp_register.php
##            includes/functions_user.php
##            language/en/ucp.php
##            language/en/acp/common.php
##
################################################################################
##
##  Full support for this MOD can be obtained at:
##
##  http://www.alexdoolittle.com
##
################################################################################
##
##   2009-03-21 - Version 1.0.2
##    - Invoked SFS IP check using Roshan getRealIpAddr() function (mx_s)
##   2009-01-18 - Version 1.0.1
##    - corrected stopforumspam.com connectivity check, error log via ACP
##    - added registration logging when reg is blocked, admin log via acp
##   2008-12-12 - Version 1.0.0
##    - first release
##
################################################################################
##
##  This mod is released under the GNU GPL v2.
##
################################################################################
##
##  BEFORE ADDING THIS MOD TO YOUR FORUM, please be sure to backup ALL
##  affected files.
##
################################################################################
#
#----------[ OPEN ]-------------------------------------
#

includes/ucp/ucp_register.php

#
#----------[ FIND ]-------------------------------------
#

         'tz'            => request_var('tz', (float) $timezone),

#
#----------[ AFTER, ADD ]-------------------------------
#

         // StopForumSpam.com API, IP variable
         'address'         => getenv('REMOTE_ADDR'),

#
#----------[ FIND ]-------------------------------------
#

            'lang'            => array('match', false, '#^[a-z_\-]{2,}$#i'),

#
#----------[ AFTER, ADD ]-------------------------------
#

            // StopForumSpam.com API, call
            'address'         => array('address')

#
#----------[ OPEN ]-------------------------------------
#

includes/functions_user.php

#
#----------[ FIND ]-------------------------------------
#

   foreach ($bad_usernames as $bad_username)
   {
      if (preg_match('#^' . $bad_username . '$#', $clean_username))
      {
         return 'USERNAME_DISALLOWED';
      }
   }

#
#----------[ AFTER, ADD ]-------------------------------
#

   // StopForumSpam.com API, Username Check
   $sfs_check = stopforumspam($username, "username");
   if ( $sfs_check )
   {
      add_log('admin', 'SFS_BLOCK_USER', $username);
      return 'USERNAME_DISALLOWED';
   }


#
#----------[ FIND ]-------------------------------------
#

      if ($row)
      {
         return 'EMAIL_TAKEN';
      }
   }

#
#----------[ AFTER, ADD ]-------------------------------
#


   // StopForumSpam.com API, Email Check
   $sfs_check = stopforumspam($email, "email");
   if ( $sfs_check )
   {
      add_log('admin', 'SFS_BLOCK_EMAIL', $email);
      return 'EMAIL_BANNED';
   }
   
   
   // Get real IP address using Roshan's provided function
   $ipaddr = getRealIpAddr();
   
   // StopForumSpam.com API, IP check
   // Check SFS global banlist
   $sfs_check = stopforumspam($ipaddr, "ip");
   if ( $sfs_check )
   {
      add_log('admin', 'SFS_BLOCK_IP', $ipaddr);
      return 'IP_BANNED';
   }
   
#
#----------[ FIND ]-------------------------------------
#

?>

#
#----------[ BEFORE, ADD ]------------------------------
#

// Roshan blog site    http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html
function getRealIpAddr()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}


// StopForumSpam.com API connector
function stopforumspam($value, $type)
{
   $sfs_request_url = "http://www.stopforumspam.com/api?$type=$value";
   $sfs_doc = new DOMDocument();
   if (!$sfs_doc->load($sfs_request_url))
   {
      // On communication error, return false and log occurence
      $sfs_appears = "no";
      add_log('critical', 'SFS_ERROR');
   }
   else
   {
      $sfs_appears = $sfs_doc->getElementsByTagName("appears")->item(0)->nodeValue;
   }

   // If the data appears on the blacklist
   return ($sfs_appears == "yes") ? true : false;
}

#
#----------[ OPEN ]-------------------------------------
#

language/en/ucp.php

#
#----------[ FIND ]-------------------------------------
#

   'INVALID_CHARS_NEW_PASSWORD'=> 'The password does not contain the required characters.',

#
#----------[ AFTER, ADD ]-------------------------------
#

   'IP_BANNED'               => 'Your IP address is not permitted to register.',

#
#----------[ OPEN ]-------------------------------------
#

language/en/acp/common.php

#
#----------[ FIND ]-------------------------------------
#

   'LOG_WORD_EDIT'         => '<strong>Edited word censor</strong><br />» %s',   

#
#----------[ AFTER, ADD ]-------------------------------
#

   'SFS_ERROR'               => '<strong>Registration blacklist cannot be contacted</strong> >> %s',
   'SFS_BLOCK_EMAIL'            => '<strong>Known spam registration via blocked email</strong> >> %s',
   'SFS_BLOCK_IP'               => '<strong>Known spam registration via blocked IP</strong> >> %s',
   'SFS_BLOCK_USER'            => '<strong>Known spam registration via blocked username</strong> >> %s',

#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM


3D-Based Captcha: Completely Automated Public Turing tests to tell Computers and Humans Apart

How They'll Break 3D Captcha
mxsquid
Site Admin
 
Posts: 543
Joined: 22 Mar 2008, 18:52


Return to JPL and Other Daydreams

Who is online

Users browsing this forum: No registered users and 1 guest

cron