Official hpHosts Support Forums
https://forum.hosts-file.net/

Patch: Functions.php (LogSpammerToFile)
https://forum.hosts-file.net/viewtopic.php?f=68&t=2211
Page 1 of 1

Author:  MysteryFCM () [ Tue Jan 11, 2011 2:00 pm ]
Post subject:  Patch: Functions.php (LogSpammerToFile)

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 257 times

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/