Check Website
Inclusion Status
It is currently Thu Sep 20, 2018 10:39 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Patch: Functions.php (LogSpammerToFile)
PostPosted: Tue Jan 11, 2011 2:00 pm 
Offline
Site Admin

Joined: Thu May 28, 2009 10:25 am
Posts: 6016
This is a patch for an issue that's been identified with the LogSpammerToFile function preventing check_spammers_plain working, and causing an issue with check_spammers (used by index.php for the SBST GUI).

If you'd like to save time downloading, just replace the LogSpammersToFile function in functions.php with;

Code:
// Used to increment and log spammers to text file (if enabled)
//
//   Requires:
//
//      $sLogPath   = Path to the folder you'd like the text files created
//      $sLDB      = Database the spammer was listed in (fSpamList, StopForumSpam, SpamCop etc)
//      $sLName      = Spammers username
//      $sLIP      = Spammers IP address
//      $sLMail      = Spammers e-mail address
//
//   Usage:
//
//      $lRet = LogSpammerToFile('./spambots/', 'fSpamList', 'volter', '123.123.123.123', 'spammer@email.com')
//
function LogSpammerToFile($sLogPath, $sLDB, $sLName, $sLIP, $sLMail){
   if($bln_SaveToFile==true){
      if(file_exists($sLogPath) == false){
         return false;
      }
      if(function_exists('file_put_contents')==false){
         echo 'You\'ve asked me to dump the results to text file, but file_put_contents is not available. Please enable it or disable dumping to a text file';
         return false;
      }
      if(ini_get('allow_url_fopen') == false){
         echo 'Unable to save to file, allow_url_fopen is disabled on this server';
         return false;
      }

      // We need a spammer database
      if($sLDB==''){
         return false;
      }else{
         //
         //   bs_      = BotScout
         //   fsl_      = fSpamlist
         //   sfs_      = StopForumSpam
         //   php_      = ProjectHoneyPot
         //   sorbs_      = Sorbs
         //   spamhaus_   = SpamHaus
         //   scop_      = SpamCop
         //   drone_      = DroneBL
         switch($sLDB){
            case "BotScout";
               $sSpamDB ='bs_';
               break;
            case "fSpamlist";
               $sSpamDB ='fsl_';
               break;
            case "StopForumSpam";
               $sSpamDB ='sfs_';
               break;
            case "ProjectHoneyPot";
               $sSpamDB ='php_';
               break;
            case "Sorbs";
               $sSpamDB ='sorbs_';
               break;
            case "SpamHaus";
               $sSpamDB ='spamhaus_';
               break;
            case "SpamCop";
               $sSpamDB ='scop_';
               break;
            case "DroneBL";
               $sSpamDB ='drone_';
               break;
            case "AHBL";
               $sSpamDB ='ahbl_';
               break;
         }
         // If any of the vars are empty, change them to "NULL"
         if($sLName==''){$sLName='NULL';}
         if($sLIP==''){$sLIP='NULL';}
         if($sLMail==''){$sLMail='NULL';}

         // Since our text files are created using the e-mail address as part of the name
         // we can't have an empty e-mail address, or it's not going to work is it?
         //
         // In this case, we'll skip the text files creation

         if($sLMail !='NULL'){
            $file = str_replace('*', '', $sLMail);
            if(file_exists($sLogPath.$sSpamDB.$file.'.txt')){
               $spambot_old_info = file_get_contents($sLogPath.$sSpamDB.$file.'.txt');
               $spambot_old_info = explode(',',$spambot_old_info);
               $spambot_old_info[2] = $spambot_old_info[2]+1; // Increase count
               $spambot_old_info = implode(',',$spambot_old_info);
               if(ini_get('allow_url_fopen') == true){
                  file_put_contents($sLogPath.$sSpamDB.$file.'.txt',$spambot_old_info);
               }
            }else{
               $spambot_info = $sLIP.','.$sLName.',1';
               if(ini_get('allow_url_fopen') == true){
                  file_put_contents($sLogPath.$sSpamDB.$file.'.txt',$spambot_info);
               }
            } // End if(file_exists($sLogPath.$sSpamDB.$file.'.txt'))

            return true;
         }else{
            return false;
         }
      }

   } // End if($bln_SaveToFile==true....
}


Attachments:
File comment: Patch for functions.php
sbst_patch_functions.php.zip [4.81 KiB]
Downloaded 247 times

_________________
Regards
Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

IP:
top
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
hpHosts and hpHosts Online are copyright © Malwarebytes Corp - All Rights Reserved

Powered by phpBB © 2000-2009 phpBB Group