-
Notifications
You must be signed in to change notification settings - Fork 9
/
import.cgi
executable file
·72 lines (63 loc) · 2.01 KB
/
import.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
#!/usr/local/bin/perl
# Try to associate a domain registration with this server
use strict;
no strict 'refs';
use warnings;
our (%access, %text, %in);
our $module_name;
require './virtualmin-registrar-lib.pl';
&ReadParse();
&error_setup($text{'import_err'});
$access{'registrar'} || &error($text{'import_ecannot'});
# Get the Virtualmin domain and account
my $d = &virtual_server::get_domain_by("dom", $in{'dom'});
$d || &error(&text('contact_edom', $in{'dom'}));
$d->{$module_name} && &error($text{'import_ealready'});
my ($account) = grep { $_->{'id'} eq $in{'account'} }
&list_registrar_accounts();
$account || &error(&text('contact_eaccount', $in{'dom'}));
my $oldd = { %$d };
# Show import progress
&ui_print_unbuffered_header(&virtual_server::domain_in($d),
$text{'import_title'}, "");
print &text('import_doing', "<tt>$d->{'dom'}</tt>",
"<i>$account->{'desc'}</i>"),"<br>\n";
my $ifunc = "type_".$account->{'registrar'}."_owned_domain";
my ($ok, $msg) = &$ifunc($account, $d->{'dom'},
$in{'id_def'} ? undef : $in{'id'});
if (!$ok) {
print &text('import_failed', $msg),"<p>\n";
}
elsif (!$msg) {
print $text{'import_missing'},"<p>\n";
}
else {
print &text('import_done', $msg),"<p>\n";
# Update the domain
$d->{$module_name} = 1;
$d->{'registrar_account'} = $account->{'id'};
$d->{'registrar_id'} = $msg;
&virtual_server::save_domain($d);
# Set nameservers to match this system
if ($in{'ns'}) {
print $text{'import_nsing'},"<br>\n";
my $nfunc = "type_".$account->{'registrar'}."_set_nameservers";
my $err = &$nfunc($account, $d);
if ($err) {
print &text('import_failed', $err),"<p>\n";
}
else {
no warnings "once";
print $virtual_server::text{'setup_done'},"<p>\n";
use warnings "once";
}
}
# Update the Webmin user
&virtual_server::refresh_webmin_user($d);
&virtual_server::run_post_actions();
# Call any theme post command
if (defined(&theme_post_save_domain)) {
&theme_post_save_domain($d, 'modify');
}
}
&ui_print_footer(&virtual_server::domain_footer_link($d));