Changeset 178

Show
Ignore:
Timestamp:
09/07/07 22:09:46 (16 months ago)
Author:
jonas
Message:

Added: md5sum of .mailfiter will be saved to database

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r175 r178  
    99        o Added: check if php-imap is enabled 
    1010        o Added: lang selection per user/sadmin 
     11        o Added: md5sum of .mailfiter will be saved to database 
    1112        o Improved: removed reload to domain show on save emailaddress 
    1213        o Fixed: autoresponder.pl. UTF-8 problems in body 
  • trunk/system_scripts/create_mailfilters.pl

    r171 r178  
    2121use Config::General; 
    2222use Proc::PID::File; 
     23use Digest::MD5; 
    2324 
    2425my $conf = new Config::General("/etc/cpves/mail_config.conf"); 
     
    122123                return $default; 
    123124        } 
     125} 
     126 
     127sub update_email_option($$$) { 
     128        my $uid = $_[0]; 
     129        my $conf = $_[1]; 
     130        my $value = $_[2]; 
     131        my $eo_sth = $dbh->prepare("SELECT id FROM email_options WHERE email=? AND conf=?"); 
     132        $eo_sth->execute($uid,$conf); 
     133        if ($eo_sth->rows==1) { 
     134                my @row_eo=$eo_sth->fetchrow_array; 
     135                my $sql=sprintf("UPDATE email_options SET options=%s WHERE email=%d AND conf=%s", 
     136                        $dbh->quote($value), 
     137                        $dbh->quote($uid), 
     138                        $dbh->quote($conf)); 
     139                $dbh->do($sql); 
     140                undef($sql); 
     141        } 
     142        else { 
     143                my $eou_sth = $dbh->prepare("INSERT INTO email_options SET email=?,conf=?,options=?"); 
     144                $eou_sth->execute($uid,$conf,$value); 
     145        } 
     146        return 0; 
     147 
    124148} 
    125149 
     
    238262                        undef $handle; 
    239263                        `chmod 600 $path/.mailfilter`; 
     264 
     265                        open(FILE ,  $path ."/.mailfilter"); 
     266                        binmode(FILE); 
     267                        my $md5sum =Digest::MD5->new->addfile(*FILE)->hexdigest; 
     268                        close(FILE); 
     269                        update_email_option($id,"mailfilter_md5",$md5sum); 
     270                        undef($md5sum); 
     271                         
    240272                } 
    241273                undef $mailfilter;