Private
Server IP : 195.201.23.43  /  Your IP : 3.137.210.249
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/virtual-server/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/virtual-server/save_mail.cgi
#!/usr/bin/perl
# Save email-related options for a virtual server

require './virtual-server-lib.pl';
&ReadParse();
&error_setup($text{'mail_err'});
$d = &get_domain($in{'dom'});
&can_edit_domain($d) && &can_edit_mail() || &error($text{'edit_ecannot'});
$oldd = { %$d };
&require_mail();

# Validate inputs
if ($supports_bcc) {
	$in{'bcc_def'} || $in{'bcc'} =~ /^\S+\@\S+$/ ||
		&error($text{'mail_ebcc'});
	}

&ui_print_unbuffered_header(&domain_in($d), $text{'mail_title'}, "");

# Update BCC setting
if ($supports_bcc) {
	$bcc = &get_domain_sender_bcc($d);
	if (!$in{'bcc_def'}) {
		# Update BCC setting
		&$first_print(&text('mail_bccing', $in{'bcc'}));
		&save_domain_sender_bcc($d, $in{'bcc'});
		&$second_print($text{'setup_done'});
		$changed++;
		}
	elsif ($bcc && $in{'bcc_def'}) {
		# Turn off BCC
		&$first_print($text{'mail_nobcc'});
		&save_domain_sender_bcc($d, undef);
		&$second_print($text{'setup_done'});
		$changed++;
		}
	}
if ($supports_bcc == 2) {
	$rbcc = &get_domain_recipient_bcc($d);
	if (!$in{'rbcc_def'}) {
		# Update BCC setting
		&$first_print(&text('mail_rbccing', $in{'rbcc'}));
		&save_domain_recipient_bcc($d, $in{'rbcc'});
		&$second_print($text{'setup_done'});
		$changed++;
		}
	elsif ($rbcc && $in{'rbcc_def'}) {
		# Turn off BCC
		&$first_print($text{'mail_norbcc'});
		&save_domain_recipient_bcc($d, undef);
		&$second_print($text{'setup_done'});
		$changed++;
		}
	}

# Update alias mode
if (defined($in{'aliascopy'}) && $d->{'mail'}) {
	$aliasdom = &get_domain($d->{'alias'});
	if ($d->{'aliascopy'} && !$in{'aliascopy'}) {
		# Switch to catchall
		&$first_print($text{'save_aliascopy0'});
		&delete_alias_virtuals($d);
		&create_virtuser({ 'from' => '@'.$d->{'dom'},
				   'to' => [ '%1@'.$aliasdom->{'dom'} ] });
		&$second_print($text{'setup_done'});
		$changed++;
		}
	elsif (!$d->{'aliascopy'} && $in{'aliascopy'}) {
		# Switch to copy mode
		&$first_print($text{'save_aliascopy1'});
		&copy_alias_virtuals($d, $aliasdom);
		&$second_print($text{'setup_done'});
		$changed++;
		}
	$d->{'aliascopy'} = $in{'aliascopy'};
	}

# Update outgoing IP mode
if (defined($in{'dependent'}) && $supports_dependent) {
	$old_dependent = &get_domain_dependent($d) ? 1 : 0;
	if ($old_dependent != $in{'dependent'}) {
		&$first_print($in{'dependent'} ?
				&text('mail_dependenting1', $d->{'ip'}) :
				&text('mail_dependenting0'));
		&save_domain_dependent($d, $in{'dependent'});
		&$second_print($text{'setup_done'});
		$changed++;
		}
	}

# Update cloud mail provider
$oldprov = &get_domain_cloud_mail_provider($d);
if ($in{'cloud'}) {
	@provs = &list_cloud_mail_providers($d, $in{'cloudid'});
	($prov) = grep { $_->{'name'} eq $in{'cloud'} } @provs;
	$prov || &error($text{'mail_ecloud'});
	if ($prov->{'id'} && !$in{'cloudid'}) {
		&error($text{'mail_ecloudid'});
		}
	if (!$oldprov ||
	    $prov->{'name'} ne $oldprov->{'name'} ||
	    $in{'cloudid'} ne $d->{'cloud_mail_id'}) {
		&$first_print(&text('mail_cloudon', $prov->{'name'}));
		&save_domain_cloud_mail_provider($d, $prov, $in{'cloudid'});
		&$second_print($text{'setup_done'});
		$changed++;
		}
	}
else {
	if ($oldprov) {
		&$first_print(&text('mail_cloudoff'));
		&save_domain_cloud_mail_provider($d, undef);
		&$second_print($text{'setup_done'});
		$changed++;
		}
	}

# Update cloud SMTP provider
$oldsmtp = $d->{'smtp_cloud'};
$cloudsmtp = $in{'smtp_cloud'};
if (defined($cloudsmtp) && $oldsmtp ne $cloudsmtp) {
	my $oldfailed = 0;
	my @clouds = &list_smtp_clouds();
	if ($oldsmtp) {
		# Turn off the old provider
		my ($c) = grep { $_->{'name'} eq $oldsmtp } @clouds;
		&$first_print(&text('mail_smtp_cloudoff', $c->{'desc'}));
		my $sfunc = "smtpcloud_".$oldsmtp."_delete_domain";
		my $info = { 'domain' => $d->{'dom'},
			     'id' => $d->{'smtp_cloud_id'},
			     'location' => $d->{'smtp_cloud_location'}};
		my ($ok, $err) = &$sfunc($d, $info);
		if ($err) {
			&$second_print(&text('mail_smtp_cloudfailed', $err));
			$oldfailed = 1;
			}
		else {
			delete($d->{'smtp_cloud'});
			delete($d->{'smtp_cloud_id'});
			&update_smtpcloud_spf($d, $oldsmtp);
			&$second_print($text{'setup_done'});
			}
		$changed++;
		}
	if ($cloudsmtp && !$oldfailed) {
		# Setup the new provider
		my ($c) = grep { $_->{'name'} eq $cloudsmtp } @clouds;
		&$first_print(&text('mail_smtp_cloudon', $c->{'desc'}));
		my $sfunc = "smtpcloud_".$cloudsmtp."_create_domain";
		my $info = { 'domain' => $d->{'dom'} };
		my ($ok, $id, $location) = &$sfunc($d, $info);
		if ($ok) { 
			$d->{'smtp_cloud'} = $cloudsmtp;
			$d->{'smtp_cloud_id'} = $id;
			$d->{'smtp_cloud_location'} = $location;
			&update_smtpcloud_spf($d, undef);
			&$second_print($text{'setup_done'});
			}
		else {
			&$second_print(&text('mail_smtp_cloudfailed', $id));
			}
		$changed++;
		}
	}

if (!$changed) {
	&$first_print($text{'mail_nothing'});
	}

&save_domain($d);
&run_post_actions();

# All done
&webmin_log("mail", "domain", $d->{'dom'});
&ui_print_footer(&domain_footer_link($d),
		 "", $text{'index_return'});

Private