forked from virtualmin/virtualmin-registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.cgi
executable file
·47 lines (42 loc) · 1.16 KB
/
create.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
#!/usr/local/bin/perl
# Create a new registrar account
use strict;
no strict 'refs';
use warnings;
our (%access, %text, %in);
require './virtualmin-registrar-lib.pl';
&error_setup($text{'create_err'});
$access{'registrar'} || &error($text{'create_ecannot'});
&ReadParse();
my $reg = $in{'registrar'};
# Validate and store inputs
my $account = { 'id' => time().$$,
'registrar' => $reg,
'enabled' => 1 };
$in{'desc'} =~ /\S/ || &error($text{'save_edesc'});
$account->{'desc'} = $in{'desc'};
my $pfunc = "type_".$reg."_create_parse";
my $err = &$pfunc($account, \%in);
&error($err) if ($err);
# Do the creation
&ui_print_unbuffered_header(undef, $text{'create_title'}, "", "create");
my $dfunc = "type_".$reg."_desc";
print &text('create_doing', &$dfunc()),"<br>\n";
my $cfunc = "type_".$reg."_create_account";
my ($ok, $msg, $warn, $extra) = &$cfunc($account);
if ($ok) {
if ($warn) {
print &text('create_warn', $msg, $warn),"<p>\n";
}
else {
print &text('create_done', $msg),"<p>\n";
}
&save_registrar_account($account);
}
else {
print &text('create_failed', $msg),"<p>\n";
}
if ($extra) {
print $extra,"<p>\n";
}
&ui_print_footer("", $text{'index_return'});