-
Notifications
You must be signed in to change notification settings - Fork 9
/
delete.cgi
executable file
·77 lines (72 loc) · 1.98 KB
/
delete.cgi
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
#!/usr/local/bin/perl
# Enable, disable or delete a bunch of accounts
use strict;
no strict 'refs';
use warnings;
our (%access, %text, %in);
require './virtualmin-registrar-lib.pl';
$access{'registrar'} || &error($text{'edit_ecannot'});
&ReadParse();
# Get the accountS
my %d = map { $_, 1 } split(/\0/, $in{'d'});
my @delaccounts = grep { $d{$_->{'id'}} } &list_registrar_accounts();
if ($in{'disable'}) {
# Disable selected
&error_setup($text{'delete_err1'});
@delaccounts || &error($text{'delete_enone'});
foreach $a (@delaccounts) {
$a->{'enabled'} = 0;
&save_registrar_account($a);
}
&webmin_log("disable", undef, scalar(@delaccounts));
&redirect("");
}
elsif ($in{'enable'}) {
# Enable selected
&error_setup($text{'delete_err2'});
@delaccounts || &error($text{'delete_enone'});
foreach my $a (@delaccounts) {
$a->{'enabled'} = 1;
&save_registrar_account($a);
}
&webmin_log("enable", undef, scalar(@delaccounts));
&redirect("");
}
elsif ($in{'delete'}) {
# Delete selected, if not used and if the user confirms
&error_setup($text{'delete_err3'});
@delaccounts || &error($text{'delete_enone'});
foreach my $a (@delaccounts) {
my @doms = &find_account_domains($a);
if (@doms) {
&error(&text('delete_edoms', "<i>$a->{'desc'}</i>",
join(" ", map { "<tt>$_->{'dom'}</tt>" } @doms)));
}
}
if ($in{'confirm'}) {
# Do it
foreach my $a (@delaccounts) {
&delete_registrar_account($a);
}
&webmin_log("delete", undef, scalar(@delaccounts));
&redirect("");
}
else {
# Ask first
&ui_print_header(undef, $text{'delete_title'}, "");
print &ui_form_start("delete.cgi", "post");
foreach my $a (@delaccounts) {
print &ui_hidden("d", $a->{'id'});
}
print &ui_hidden("delete", 1);
print "<center>",
&text('delete_rusure', scalar(@delaccounts)),"<p>\n",
&ui_submit($text{'delete_ok'}, 'confirm'),
"</center>\n";
print &ui_form_end();
&ui_print_footer("", $text{'index_return'});
}
}
else {
&error("No button clicked!");
}