File: disable_domain.cgi

package info (click to toggle)
webmin-virtual-server 2.50-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,608 kB
  • ctags: 392
  • sloc: perl: 15,687; makefile: 95; sh: 8
file content (95 lines) | stat: -rwxr-xr-x 2,735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/local/bin/perl
# disable_domain.cgi
# Temporarily disable a domain, after asking first

require './virtual-server-lib.pl';
&ReadParse();
$d = &get_domain($in{'dom'});
$access{'edit'} && &can_edit_domain($d) || &error($text{'edit_ecannot'});
$d->{'disabled'} && &error($text{'disable_ealready'});

if ($in{'confirm'}) {
	&ui_print_unbuffered_header(undef, $text{'disable_title'}, "");
	}
else {
	&ui_print_header(undef, $text{'disable_title'}, "");
	}

# Work out what can be disabled
@disable = grep { $d->{$_} && $config{$_} } split(/,/, $config{'disable'});
push(@disable, "ssl") if (&indexof("web", @disable) >= 0 && $d->{'ssl'});
@disable = grep { $_ ne "unix" } @disable if ($d->{'parent'});
push(@disable, grep { $d->{$_} &&
	      &plugin_defined($_, "feature_disable") } @feature_plugins);

if (!@disable) {
	# Nothing to do!
	print "<p>$text{'disable_nothing'}<p>\n";
	}
elsif (!$in{'confirm'}) {
	# Ask the user if he is sure
	@distext = map { $text{"disable_f".$_} ||
			 &plugin_call($_, "feature_disname") } @disable;
	if (@distext == 1) {
		$distext = $distext[0];
		}
	elsif (@distext == 2) {
		$distext = &text('disable_and', $distext[0], $distext[1]);
		}
	else {
		$dislast = pop(@distext);
		$distext = &text('disable_and', join(", ", @distext), $dislast);
		}

	print &check_clicks_function();
	print "<p>",&text('disable_rusure2', "<tt>$d->{'dom'}</tt>",
			  $distext),"<p>\n";
	print $text{'disable_undo'},"<p>\n";
	print "<center><form action=disable_domain.cgi>\n";
	print "<input type=hidden name=dom value='$in{'dom'}'>\n";
	print "<input type=submit name=confirm ",
	      "value='$text{'disable_ok'}' onClick='check_clicks(form)'>\n";
	print "</form></center>\n";
	}
else {
	# Go ahead and do it ..
	%disable = map { $_, 1 } @disable;

	# Run the before command
	&set_domain_envs($d, "DISABLE_DOMAIN");
	$merr = &making_changes();
	&error(&text('disable_emaking', "<tt>$merr</tt>")) if (defined($merr));

	# Disable all configured features
	my $f;
	foreach $f (@features) {
		if ($d->{$f} && $disable{$f}) {
			local $dfunc = "disable_$f";
			&$dfunc($d);
			push(@disabled, $f);
			}
		}
	foreach $f (@feature_plugins) {
		if ($d->{$f} && $disable{$f}) {
			&plugin_call($f, "feature_disable", $d);
			push(@disabled, $f);
			}
		}

	# Save new domain details
	print $text{'save_domain'},"<br>\n";
	$d->{'disabled'} = join(",", @disabled);
	$d->{'disabled_reason'} = 'manual';
	&save_domain($d);
	print $text{'setup_done'},"<p>\n";

	# Run the after command
	&run_post_actions();
	&set_domain_envs($d, "DISABLE_DOMAIN");
	&made_changes();
	&webmin_log("disable", "domain", $d->{'dom'}, $d);
	}

&ui_print_footer("edit_domain.cgi?dom=$in{'dom'}", $text{'edit_return'},
	"", $text{'index_return'});