Firefox PHP

A way to make censor erase the whole msg (Phorum 3)

Posted by davix 
A way to make censor erase the whole msg (Phorum 3)
September 17, 2006 08:59PM
I am using Phorum 3 (and will not upgrade for my admin dosen't want me to):
As a last resort for spam block I have decided to use the censor to block messages with malicious spam content and my question is: Can I change the routine in post.php to delete the message instead of just replacing it with $!$?

here is the code
function censor($author, $subject, $email, $body) {
    global $include_path, $ForumConfigSuffix;
    if(file_exists("$include_path/censor_$ForumConfigSuffix.php")){
      include "$include_path/censor_$ForumConfigSuffix.php";
    } else {
      include "$include_path/censor.php";
    }

    $blurb = "@!#$";
    if (is_array($profan)) {
      reset($profan);
      while (list(, $sWord) = each($profan)) {
        if(strstr(strtoupper($author), strtoupper($sWord))){
          if(strtoupper($author)==strtoupper($sWord)) $author=$blurb;
          $author = eregi_replace("^$sWord([^a-zA-Z])", "$blurb\\1", $author);
          $author = eregi_replace("([^a-zA-Z])$sWord$", "\\1$blurb", $author);
          while(eregi("([^a-zA-Z])($sWord)([^a-zA-Z])", $author)){
            $author = eregi_replace("([^a-zA-Z])($sWord)([^a-zA-Z])", "\\1$blurb\\3", $author);
          }
        }
        if(strstr(strtoupper($subject), strtoupper($sWord))){
          if(strtoupper($subject)==strtoupper($sWord)) $subject=$blurb;
          $subject = eregi_replace("^$sWord([^a-zA-Z])", "$blurb\\1", $subject);
          $subject = eregi_replace("([^a-zA-Z])$sWord$", "\\1$blurb", $subject);
          while(eregi("([^a-zA-Z])($sWord)([^a-zA-Z])", $subject)){
            $subject = eregi_replace("([^a-zA-Z])($sWord)([^a-zA-Z])", "\\1$blurb\\3", $subject);
          }
        }
        if(strstr(strtoupper($email), strtoupper($sWord))){
          if(strtoupper($email)==strtoupper($sWord)) $email="";
          $email = eregi_replace("^$sWord([^a-zA-Z])", "$blurb\\1", $email);
          $email = eregi_replace("([^a-zA-Z])$sWord$", "\\1$blurb", $email);
          while(eregi("([^a-zA-Z])($sWord)([^a-zA-Z])", $email)){
            $email = eregi_replace("([^a-zA-Z])($sWord)([^a-zA-Z])", "\\1$blurb\\3", $email);
          }
        }
        if(strstr(strtoupper($body), strtoupper($sWord))){
          if(strtoupper($body)==strtoupper($sWord)) $body=$blurb;
          $body = eregi_replace("^$sWord([^a-zA-Z])", "$blurb\\1", $body);
          $body = eregi_replace("([^a-zA-Z])$sWord$", "\\1$blurb", $body);
          while(eregi("([^a-zA-Z])($sWord)([^a-zA-Z])", $body)){
            $body = eregi_replace("([^a-zA-Z])($sWord)([^a-zA-Z])", "\\1$blurb\\3", $body);
          }
        }
      }
    }
    return(array($author, $subject, $email, $body));
  }
My knowledge of php lacks, to say the least so I wonder if some one can tell me, what need I change in order to delete the messege and not cause errors in the ending of the code.

If it's not possible, how can I make a function that will act like censor but will delete the messege with no problems for the completion of the loop, thank you all.
Re: A way to make censor erase the whole msg (Phorum 3)
September 25, 2006 05:11AM
please help
Re: A way to make censor erase the whole msg (Phorum 3)
September 25, 2006 10:40AM
Please convince your admin to let you upgrade Phorum to a current version. There's no support for Phorum 3

---
-=[ Panu ]=-
Re: A way to make censor erase the whole msg (Phorum 3)
September 25, 2006 03:22PM
Hi Davix,

Quote
davix
Can I change the routine in post.php to delete the message instead of just replacing it with $!$?

I copied the behavior of the bad_*.php-scripts in the include directory.

Make a new file /include/bad_words.php:

<?php
  // to use this file add a line like this:
  // $badwords[]='badword';
  // regexp can be used
  $badwords[]='incest';
?>

Add to /include/post_functions.php (for example after the check_email-function):

  // Check message against bad words list.
  // Returns true if ok, false if bad.
  function check_message($message) {
    global $include_path, $ForumConfigSuffix;
    if(file_exists("$include_path/bad_words_$ForumConfigSuffix.php")){
      include "$include_path/bad_words_$ForumConfigSuffix.php";
    } else {
      include "$include_path/bad_words.php";
    }
    if(@is_array($badwords)){
      reset($badwords);
      while (list(, $badword) = each($badwords)) {
        if (eregi($badword, $message)) {
          return(false);
        }
      }
    }
    return(true);
  }

Add to check_data-function in /include/post_functions.php after the first if-statement:

    if (!check_message($body)) {
      violation();
    }

Regards
Oliver


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Sorry, only registered users may post in this forum.

Click here to login