hello list,

here a little php script for converting old filters. it must be in the
MAIL_ROOT path

the array $filters defines the filters, in the example a virus and a spam
filter

"/var/MailRoot/avfilter/viruscheck.pl" => array(    "virus.tab"       ,
true,         true),
      the filter path                             the new filterfile
in            out

for each old filter it will be checked, if the old filter has the filter
path in it, and if matched, it'll add the filter in the new filter file.

with "in" and "out" you can define, if the filter should be added to the new
filter files. so in the example the virus filter is for "in" and "out", the
spam filter only for "in".

the new .tab files with the filters in it must exist, of course.

it's tested by myself and i hope that helps. ;-)

filterconvert.php:

#!/usr/bin/php
<?
$dirname="filters";
$dir=dir($dirname);


$filters=array(
 "/var/MailRoot/avfilter/viruscheck.pl" => array("virus.tab", true, true),
 "/var/MailRoot/avfilter/spam.pl" => array("spam.tab", true, false)
);

$in=fopen("filters.in.tab", "w");
$out=fopen("filters.out.tab", "w");

while ($file=$dir->read()) {
 if (!is_file("$dirname/$file")) {
  continue;
 }

 $email=substr($file, 0, -4);

 if (strstr($email, "@")) {
  list($user, $domain)=explode("@", $email);
 } else {
  $user="*";
  $domain=$email;
 }

 $oldfilter=file("$dirname/$file");
 foreach ($filters as $filter => $data) {
  foreach ($oldfilter as $oldfilterline) {
   if (ereg($filter, $oldfilterline)) {

$line="\"*\"\t\"$user@$domain\"\t\"0.0.0.0/0\"\t\"0.0.0.0/0\"\t\"$data[0]\"\
n";
    if ($data[1]) {
     fwrite($in, $line);
    }
    if ($data[2]) {
     echo "juchu";
     fwrite($out, $line);
    }
   }
  }
 }


}

fclose($in);
fclose($out);
?>


-- Binary/unsupported file stripped by Ecartis --
-- Type: application/x-pkcs7-signature
-- File: smime.p7s


-
To unsubscribe from this list: send the line "unsubscribe xmail" in
the body of a message to [EMAIL PROTECTED]
For general help: send the line "help" in the body of a message to
[EMAIL PROTECTED]

Reply via email to