HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: 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,pcntl_unshare,
Upload Files
File: //usr/share/webmin/virtual-server/clone.cgi
#!/usr/bin/perl
# DUplicate a virtual server

require './virtual-server-lib.pl';
&ReadParse();
&error_setup($text{'clone_err'});
$d = &get_domain($in{'dom'});
$oldd = { %$d };

# Check limits
if ($d->{'parent'} && !&can_create_sub_servers() ||
    !$d->{'parent'} && !&can_create_master_servers()) {
	&error($text{'clone_ecannot'});
	}
($dleft, $dreason, $dmax) = &count_domains(
	$d->{'alias'} ? "aliasdoms" :
	$d->{'parent'} ? "realdoms" : "topdoms");
&error(&text('setup_emax', $dmax, $virtualmin_account_subscriptions)) if ($dleft == 0);

# Validate inputs
$in{'newdomain'} = lc(&parse_domain_name($in{'newdomain'}));
$err = &valid_domain_name($in{'newdomain'});
&error($err) if ($err);
$clash = &get_domain_by("dom", $in{'newdomain'});
$clash && &error($text{'clone_eclash'});
if (!$d->{'parent'}) {
	$in{'newuser'} =~ /^[^\t :]+$/ || &error($text{'setup_euser2'});
	$in{'newpass_def'} || $in{'newpass'} || &error($text{'clone_epass'});
	$clash = &get_domain_by("user", $in{'newuser'});
	$clash && &error($text{'clone_eclash2'});
	}

# Check for allowed domain name
$parent = $d->{'parent'} ? &get_domain($d->{'parent'}) : undef;
$derr = &allowed_domain_name($parent, $in{'newdomain'});
&error($derr) if ($derr);

# Validate IP address
if ($d->{'virt'} && &can_select_ip() && !$in{'ip_def'}) {
	$ip = $in{'ip'};
	$virtalready = $in{'virtalready'};
	&check_ipaddress($ip) || &error($text{'setup_eip'});
	$clash = &check_virt_clash($ip);
	if ($virtalready) {
		# Fail if the IP isn't yet active, or if claimed by another
		# virtual server
                $clash || &error(&text('setup_evirtclash2', $ip));
		$already = &get_domain_by("ip", $ip);
		$already && &error(&text('setup_evirtclash4',
                                         $already->{'dom'}));
		}
	else {
		# Fail if the IP *is* already activ
		$clash && &error(&text('setup_evirtclash'));
		}
	}

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

if ($d->{'parent'}) {
	&$first_print(&text('clone_doing',
			    $d->{'dom'}, $in{'newdomain'}));
	}
else {
	&$first_print(&text('clone_doing2',
			    $d->{'dom'}, $in{'newdomain'}, $in{'newuser'}));
	}
$ok = &clone_virtual_server($d, $in{'newdomain'}, $in{'newuser'},
			    $in{'newpass_def'} ? undef : $in{'newpass'},
			    $ip, $virtalready);
if ($ok) {
	&$second_print($text{'setup_done'});
	}
else {
	&$second_print($text{'clone_failed'});
	}

# Refresh Webmin user
&refresh_webmin_user($d);

&run_post_actions();
&webmin_log("clone", "domain", $d->{'dom'}, $d);

# Call any theme post command
$clone = &get_domain_by("dom", $in{'newdomain'});
if (defined(&theme_post_save_domain) && $clone) {
	&theme_post_save_domain($clone, 'create');
	}

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