-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathdomain_form.cgi
executable file
·662 lines (602 loc) · 20.3 KB
/
domain_form.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
#!/usr/local/bin/perl
# domain_form.cgi
# Display a form for setting up a new virtual domain
require './virtual-server-lib.pl';
&ReadParse();
if ($in{'import'}) {
# Redirect to the import form
&redirect("import_form.cgi");
return;
}
elsif ($in{'migrate'}) {
# Redirect to the migration form
&redirect("migrate_form.cgi");
return;
}
elsif ($in{'batch'}) {
# Redirect to the batch creation
&redirect("mass_create_form.cgi");
return;
}
elsif ($in{'delete'}) {
# Redirect to the mass server deletion form
@d = split(/\0/, $in{'d'});
&redirect("pro/mass_delete_domains.cgi?".join("&", map { "d=$_" } @d));
return;
}
elsif ($in{'mass'}) {
# Redirect to the mass server update form
@d = split(/\0/, $in{'d'});
&redirect("pro/mass_domains_form.cgi?".join("&", map { "d=$_" } @d));
return;
}
elsif ($in{'disable'}) {
# Redirect to mass disable form
@d = split(/\0/, $in{'d'});
&redirect("pro/mass_disable.cgi?".join("&", map { "d=$_" } @d));
return;
}
elsif ($in{'enable'}) {
# Redirect to mass enable form
@d = split(/\0/, $in{'d'});
&redirect("pro/mass_enable.cgi?".join("&", map { "d=$_" } @d));
return;
}
# Can this user even create servers?
&can_create_master_servers() || &can_create_sub_servers() ||
&error($text{'form_ecannot'});
# Get parent settings
if ($in{'to'}) {
# Creating an alias domain
$aliasdom = &get_domain($in{'to'});
$parentdom = $aliasdom->{'parent'} ?
&get_domain($aliasdom->{'parent'}) : $aliasdom;
$parentuser = $parentdom->{'user'};
}
elsif (!&can_create_master_servers()) {
# This user can only create a sub-server
if ($access{'admin'}) {
$parentdom = &get_domain($access{'admin'});
$parentuser = $parentdom->{'user'};
}
else {
$parentuser = $remote_user;
}
}
elsif ($in{'parentuser1'} || $in{'parentuser2'}) {
# Creating sub-server explicitly
$parentuser = $in{'add1'} ? $in{'parentuser1'} : $in{'parentuser2'};
}
if ($parentuser && !$parentdom) {
$parentdom = &get_domain_by("user", $parentuser, "parent", "");
$parentdom || &error(&text('form_eparent', $parentuser));
}
if ($in{'subdom'}) {
# Creating a sub-domain
$subdom = &get_domain($in{'subdom'});
$subdom || &error(&text('form_esubdom', $in{'subdom'}));
}
my $subhead = $aliasdom || $parentdom ? &domain_in($aliasdom || $parentdom) : "";
&ui_print_header($subhead, $aliasdom ? $text{'form_title3'} :
$subdom ? $text{'form_title4'} :
$parentdom ? $text{'form_title2'} :
$text{'form_title'}, "",
$aliasdom ? "create_alias" :
$subdom ? "create_subdom" :
$parentdom ? "create_subserver" : "create_form");
# Show user friendly info
my ($tdleft, $tdreason, $tdmax) = &count_domains("topdoms");
if (!$tdleft && $tdreason == 3) {
print &ui_alert_box(
&text('setup_emax', $tdmax, $virtualmin_account_subscriptions),
'warn', undef, undef, '');
}
# Form header
@tds = ( "width=30%" );
print &ui_form_start("domain_setup.cgi", "post");
print &ui_hidden("parentuser", $parentuser),"\n";
print &ui_hidden("to", $in{'to'}),"\n";
print &ui_hidden("subdom", $in{'subdom'}),"\n";
print &ui_hidden_table_start($text{'form_header'}, "width=100%", 2,
"basic", 1);
# Domain name
if ($subdom) {
# Under top-level domain
print &ui_table_row(&hlink($text{'form_domain'}, "domainname"),
&vui_noauto_textbox("dom", undef, 20).".$subdom->{'dom'}",
undef, \@tds);
}
else {
# Full domain name
local $force = $access{'forceunder'} && $parentdom ?
".$parentdom->{'dom'}" :
$access{'subdom'} ? ".$access{'subdom'}" : undef;
print &ui_table_row(&hlink($text{'form_domain'}, "domainname"),
&vui_noauto_textbox("dom", $force, 50, 0, undef,
"onBlur='domain_change(this)'"),
undef, \@tds);
# Javascript to append domain name if needed
print "<script>\n";
print "function domain_change(field)\n";
print "{\n";
if ($parentdom && !$aliasdom) {
print "if (field.value.indexOf('.') < 0) {\n";
print " field.value += '.".$parentdom->{'dom'}."';\n";
print " }\n";
}
print "}\n";
print "</script>\n";
}
# Description / owner
print &ui_table_row(&hlink($text{'form_owner'}, "ownersname"),
&vui_noauto_textbox("owner", undef, 50),
undef, \@tds);
if (!$parentuser) {
# Password
print &ui_table_row(&hlink($text{'form_pass'}, "password"),
&new_password_input("vpass"),
undef, \@tds);
# SSH public key for Unix user
print &ui_table_row(&hlink($text{'form_sshkey'}, "sshkey"),
&ui_radio("sshkey_mode", 0,
[ [ 0, $text{'form_sshkey0'} ],
[ 1, $text{'form_sshkey1'} ],
[ 2, $text{'form_sshkey2'} ] ])."<br>\n".
&ui_textarea("sshkey", undef, 3, 60), undef, \@tds);
}
# Generate Javascript for template change
@availtmpls = &list_available_templates($parentdom, $aliasdom);
if ($aliasdom || $parentdom) {
# Alias and sub-servers should inherit parent template, if possible
$deftmplid = $aliasdom ? $aliasdom->{'template'}
: $parentdom->{'template'};
($deftmpl) = grep { $_->{'id'} == $deftmplid } @availtmpls;
}
if (!$deftmpl) {
$deftmplid = &get_init_template($parentdom);
($deftmpl) = grep { $_->{'id'} == $deftmplid } @availtmpls;
}
$deftmpl ||= $availtmpls[0];
$js = "<script>\n";
$js .= "function select_template(num)\n";
$js .= "{\n";
$js .= "var domain_form_target = document.querySelectorAll('form[action*=\"domain_setup.cgi\"]');\n";
foreach $t (@availtmpls) {
local $tmpl = &get_template($t->{'id'});
if (!$parentdom && &can_choose_ugroup()) {
# Set group for unix user
$js .= "if (num == $tmpl->{'id'}) {\n";
$num = $tmpl->{'ugroup'} eq "none" ? 0 : 1;
$val = $tmpl->{'ugroup'} eq "none" ? "" : $tmpl->{'ugroup'};
$js .= " domain_form_target[0].group_def[$num].checked = true;\n";
$js .= " domain_form_target[0].group.value = \"$val\";\n";
$js .= " }\n";
}
}
$js .= "}\n";
$js .= "</script>\n";
print $js;
# Work out which features are enabled by default
@dom_features = $aliasdom ? @opt_alias_features :
$subdom ? @opt_subdom_features : @opt_features;
%plugins_inactive = map { $_, 1 } @plugins_inactive;
if ($config{'plan_auto'}) {
@def_features = grep { $config{$_} == 1 || $config{$_} == 3 }
@dom_features;
@fplugins = &list_feature_plugins();
push(@def_features, grep { !$plugins_inactive{$_} } @fplugins);
}
# Generate Javascript for plan change
@availplans = sort { $a->{'name'} cmp $b->{'name'} } &list_available_plans();
$defplan = &get_default_plan();
$js = "<script>\n";
$js .= "function select_plan(num)\n";
$js .= "{\n";
$js .= "var domain_form_target = document.querySelectorAll('form[action*=\"domain\"][action*=\".cgi\"]');\n";
foreach $plan (@availplans) {
$js .= "if (num == $plan->{'id'}) {\n";
if (!$config{'template_auto'}) {
# Limits are only set if the fields exists
# Set quotas
$js .= "a_javascript("quota", $plan->{'quota'}, "home", 1);
$js .= "a_javascript("uquota", $plan->{'uquota'}, "home",1);
# Set limits
$js .= "a_javascript("mailboxlimit",$plan->{'mailboxlimit'},
"none", 1);
$js .= "a_javascript("aliaslimit", $plan->{'aliaslimit'},
"none", 1);
$js .= "a_javascript("dbslimit", $plan->{'dbslimit'},
"none", 1);
if ($config{'bw_active'}) {
$js .= "a_javascript("bwlimit", $plan->{'bwlimit'},
"bw", 1);
}
$num = $plan->{'domslimit'} eq "" ? 1 :
$plan->{'domslimit'} eq "0" ? 0 : 2;
$val = $num == 2 ? $plan->{'domslimit'} : "";
$js .= " var f = domain_form_target[0];\n";
$js .= " f.domslimit_def[$num].checked = true;\n";
$js .= " f.domslimit.value = \"$val\";\n";
# Set no database name
$js .= " f.nodbname[".int($plan->{'nodbname'}).
"].checked = true;\n";
}
# Set features if configured
if ($config{'plan_auto'}) {
local @fl = $plan->{'featurelimits'} ?
split(/\s+/, $plan->{'featurelimits'}) :
@def_features;
foreach $f (@dom_features, @fplugins) {
$js .= " if (domain_form_target[0]['$f']) {\n";
$js .= " domain_form_target[0]['$f'].checked = ".
(&indexof($f, @fl) >= 0 ? 1 : 0).";\n";
$js .= " }\n";
}
}
$js .= " }\n";
}
$js .= "}\n";
$js .= "</script>\n";
print $js;
# Show template selection field
foreach $t (&list_available_templates($parentdom, $aliasdom)) {
push(@opts, [ $t->{'id'}, $t->{'name'} ]);
push(@cantmpls, $t);
}
print &ui_table_row(&hlink($text{'form_template'},"template"),
&ui_select("template", $deftmpl->{'id'}, \@opts, 1, 0,
0, 0, $config{'template_auto'} ? "" :
"onChange='select_template(options[selectedIndex].value)'"),
undef, \@tds);
# Show plan selection field, for top-level domains
if (!$parentdom) {
foreach $p (sort { $a->{'name'} cmp $b->{'name'} }
&list_available_plans()) {
push(@popts, [ $p->{'id'}, &html_escape($p->{'name'}) ]);
}
print &ui_table_row(&hlink($text{'form_plan'}, "plan"),
&ui_select("plan", $defplan->{'id'}, \@popts, 1, 0, 0, 0,
"onChange='select_plan(options[selectedIndex].value)'"),
undef, \@tds);
}
if ($aliasdom) {
# Show destination of alias
print &ui_table_row(&hlink($text{'form_aliasdom'}, "aliasdom"),
"<a href='edit_domain.cgi?dom=$parentdom->{'id'}'>".
"$aliasdom->{'dom'}</a>",
undef, \@tds);
}
elsif ($parentdom) {
# Show parent domain
print &ui_table_row(&hlink($text{'form_parentdom'}, "parentdom"),
"<a href='edit_domain.cgi?dom=$parentdom->{'id'}'>".
"$parentdom->{'dom'}</a> (<tt>$parentuser</tt>)",
undef, \@tds);
}
if (!$parentuser) {
# Unix username
print &ui_table_row(&hlink($text{'form_user'}, "unixusername"),
&ui_opt_textbox("vuser", undef, 15,
$text{'form_auto'}, $text{'form_nwuser'}),
undef, \@tds);
}
if (!$parentuser && $config{'force_email'}) {
# Contact email address (if manadatory)
print &ui_table_row(&hlink($text{'form_email'}, "ownersemail"),
&ui_textbox("email", $config{'contact_email'}, 40),
undef, \@tds);
}
print &ui_hidden_table_end("basic");
# Start of advanced section
$has_advanced = $aliasdom ? 0 : 1;
if ($has_advanced) {
print &ui_hidden_table_start($text{'form_advanced'}, "width=100%", 2,
"advanced", 0);
}
# These settings are not needed for a sub-domain, as they come from the owner
if (!$parentuser) {
# Contact email address (if optional)
if (!$config{'force_email'}) {
print &ui_table_row(&hlink($text{'form_email'}, "ownersemail"),
&ui_opt_textbox("email", $config{'contact_email'}, 30,
$text{'form_email_def'},
$text{'form_email_set'}),
undef, \@tds);
}
# Mail group name
print &ui_table_row(&hlink($text{'form_mgroup'}, "mailgroupname"),
&ui_opt_textbox("mgroup", undef, 15,
$text{'form_auto'}, $text{'form_nwgroup'}),
undef, \@tds);
if (&can_choose_ugroup()) {
# Group for Unix user
local $ug = $deftmpl->{'ugroup'};
$ug = "" if ($ug eq "none");
print &ui_table_row(&hlink($text{'form_group'},"unixgroupname"),
&ui_opt_textbox("group", $ug, 15,
$text{'form_crgroup'},
$text{'form_exgroup'}).
&group_chooser_button("group"),
undef, \@tds);
}
}
if (!$aliasdom) {
# Show input for mail username prefix
print &ui_table_row(&hlink($text{'form_prefix'}, "prefixname"),
&ui_opt_textbox("prefix", undef, 15,
$text{'form_auto'}),
undef, \@tds);
}
else {
print &ui_hidden("prefix_def", 1),"\n";
}
if (!$aliasdom && &database_feature() && &can_edit_databases() && !$subdom) {
# Show database name field, iff this is not an alias or sub domain
print &ui_table_row(&hlink($text{'form_dbname'},"dbname"),
&ui_opt_textbox("db", undef, 15,
$text{'form_auto'}),
undef, \@tds);
}
# Show reseller selection field
if (&can_edit_templates() && defined(&list_resellers) && !$parentdom) {
@resels = &list_resellers();
if (@resels) {
print &ui_table_row(&hlink($text{'form_reseller'},"dreseller"),
&ui_select("reseller", undef,
[ [ '', $text{'form_noreseller'} ],
map { $_->{'name'} } @resels ]));
}
}
# Show remote MySQL field
if (&can_edit_templates() && $config{'mysql'} && !$aliasdom && !$parentdom) {
my @mymods = grep { !$_->{'config'}->{'virtualmin_provision'} }
&list_remote_mysql_modules();
if (@mymods > 1) {
print &ui_table_row(&hlink($text{'form_rmysql'}, "rmysql"),
&ui_select("rmysql",
&get_default_mysql_module(),
[ map { [ $_->{'minfo'}->{'dir'},
$_->{'desc'} ] } @mymods ]));
}
}
if ($has_advanced) {
print &ui_hidden_table_end("advanced");
}
# Show hidden section for limits
if (!$parentuser && !$config{'template_auto'}) {
print &ui_hidden_table_start($text{'form_limits'}, "width=100%", 2,
"limits", 0);
}
# Only display quota inputs if enabled, and if not creating a subdomain
if (&has_home_quotas() && !$parentuser && !$config{'template_auto'}) {
print &ui_table_row(&hlink($text{'form_quota'}, "websitequota"),
&opt_quota_input("quota", $defplan->{'quota'}, "home"),
undef, \@tds);
print &ui_table_row(&hlink($text{'form_uquota'}, "unixuserquota"),
&opt_quota_input("uquota", $defplan->{'uquota'}, "home"),
undef, \@tds);
}
if (!$parentdom && $config{'bw_active'} && !$config{'template_auto'}) {
# Show bandwidth limit field
print &ui_table_row(&hlink($text{'edit_bw'}, "bwlimit"),
&bandwidth_input("bwlimit", $defplan->{'bwlimit'}),
undef, \@tds);
}
if (!$parentuser && !$config{'template_auto'}) {
# Show input for limit on number of mailboxes, aliases and DBs
foreach $l ("mailbox", "alias", "dbs") {
print &ui_table_row(
&hlink($text{'form_'.$l.'limit'}, $l.'limit'),
&ui_opt_textbox($l.'limit',
$defplan->{$l.'limit'},
4, $text{'form_unlimit'},
$text{'form_atmost'}),
undef, \@tds);
}
# Show input for restriction of number of sub-domains this domain
# owner can create
local $dlm = $defplan->{'domslimit'} eq '' ? 2 :
$defplan->{'domslimit'} eq '0' ? 1 : 2;
print &ui_table_row(&hlink($text{'form_domslimit'}, "domslimit"),
&ui_radio("domslimit_def", $dlm,
[ [ 1, $text{'form_nocreate'} ],
[ 2, $text{'form_unlimit'} ],
[ 0, $text{'form_atmost'} ] ])."\n".
&ui_textbox("domslimit",
$dlm == 0 ? $config{'defdomslimit'} : "", 4),
undef, \@tds);
# Show input for default database name limit
print &ui_table_row(&hlink($text{'limits_nodbname'}, "nodbname"),
&ui_radio("nodbname", $defplan->{'nodbname'},
[ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]),
undef, \@tds);
}
if (!$parentuser && !$config{'template_auto'}) {
print &ui_hidden_table_end("limits");
}
# Show section for custom fields, if any
$fields = &show_custom_fields(undef, \@tds);
if ($fields) {
print &ui_hidden_table_start($text{'edit_customsect'}, "width=100%", 2,
"custom", 1);
print $fields;
print &ui_hidden_table_end("custom");
}
# Show checkboxes for features
print &ui_hidden_table_start($text{'edit_featuresect'}, "width=100%", 2,
"feature", 1);
@grid = ( );
@grid_order_initial = ( );
$i = 0;
$can_website = 0;
foreach $f (@dom_features) {
# Don't allow access to features that this user hasn't been
# granted for his subdomains.
next if (!&can_use_feature($f));
next if ($parentdom && $f eq "webmin");
next if ($parentdom && $f eq "unix");
next if ($aliasdom && !$aliasdom->{$f});
next if (!$config{$f} && defined($config{$f})); # Not enabled
$can_feature{$f}++;
$can_website = 1 if ($f eq 'web');
if (&can_chained_feature($f, 1)) {
# This feature is always on when some other feature is, so
# don't show it
next;
}
if (($f eq "dir" || $f eq "unix") && $config{$f} == 3) {
# These features are always on for new domains
print &ui_hidden($f, 1);
next;
}
my $ftxt = $aliasdom ? $text{'form_alias'.$f} :
$parentdom ? $text{'form_sub'.$f} : undef;
my $fhelp = $f;
$fhelp = $f."_alias" if ($aliasdom && $ftxt);
$ftxt ||= $text{'form_'.$f};
push(@grid_order_initial, $f);
push(@grid, &ui_checkbox($f, 1, "",
$config{$f} == 1 && $in{'nofeat'} ne $f,
&feature_check_chained_javascript($f)).
" <b>".&hlink($ftxt, $fhelp)."</b>");
}
# Show checkboxes for plugins
@input_plugins = ( );
@fplugins = &list_feature_plugins() if (!$config{'plan_auto'});
foreach $f (@fplugins) {
next if (!&plugin_call($f, "feature_suitable",
$parentdom, $aliasdom, $subdom));
next if (!&can_use_feature($f));
$can_website = 1 if (&plugin_call($f, "feature_provides_web"));
if (&can_chained_feature($f, 1)) {
# This feature is always on when some other feature is, so
# don't show it
next;
}
$label = &plugin_call($f, "feature_label", 0);
$label = " <b>$label</b>";
$hlink = &plugin_call($f, "feature_hlink");
$label = &hlink($label, $hlink, $f) if ($hlink);
push(@grid_order_initial, $f);
push(@grid, &ui_checkbox($f, 1, "", !$plugins_inactive{$f},
&feature_check_chained_javascript($f)).$label);
if (&plugin_call($f, "feature_inputs_show", undef)) {
push(@input_plugins, $f);
}
}
features_sort(\@grid, \@grid_order_initial);
print &ui_table_row(undef, &vui_features_sorted_grid(\@grid), 4);
print &ui_hidden_table_end("feature");
# Show section for extra plugin options
if (@input_plugins) {
print &ui_hidden_table_start($text{'form_inputssect'}, "width=100%", 2,
"inputs", 0, [ "width=30%" ]);
foreach $f (@input_plugins) {
&plugin_call($f, "load_theme_library");
print &plugin_call($f, "feature_inputs", undef);
}
print &ui_hidden_table_end("inputs");
}
# Start section for proxy and IP
print &ui_hidden_table_start($text{'form_proxysect'}, "width=100%", 2,
"proxy", 0, [ "width=30%" ]);
# Show inputs for setting up a proxy-only virtual server
if ($can_website && $config{'proxy_pass'} && !$aliasdom) {
print &frame_fwd_input();
}
# Show field for mail forwarding
if ($can_feature{'mail'} && !$aliasdom && !$subdom && &can_edit_catchall()) {
print &ui_table_row(&hlink($text{'form_fwdto'}, "fwdto"),
&ui_opt_textbox("fwdto", undef, 30, $text{'form_fwdto_none'}),
undef, \@tds);
}
# Show IP address allocation section
$resel = $parentdom ? $parentdom->{'reseller'} :
&reseller_admin() ? $base_remote_user : undef;
$defip = &get_default_ip($resel);
if ($aliasdom) {
print &ui_table_row($text{'edit_ip'}, $aliasdom->{'ip'});
}
elsif (!&can_select_ip()){
print &ui_table_row($text{'edit_ip'},
$access{'ipfollow'} && $parentdom ? $parentdom->{'ip'}
: $defip);
}
else {
my ($imode, $iip);
if ($parentdom && &indexof($parentdom->{'ip'}, &list_shared_ips()) >= 0) {
$imode = 3;
$iip = $parentdom->{'ip'};
}
print &ui_table_row(&hlink($text{'form_iface'}, "iface"),
&virtual_ip_input(\@cantmpls, $resel, undef, $imode, $iip),
undef, \@tds);
}
# Show IPv6 address allocation section
$defip6 = &get_default_ip6($resel);
if (!&supports_ip6()) {
# Not supported
print &ui_table_row($text{'edit_ip6'}, $text{'edit_noip6support'});
}
elsif ($aliasdom) {
# From alias domain
print &ui_table_row($text{'edit_ip6'}, $aliasdom->{'ip6'} ||
$text{'edit_virt6off'});
}
elsif (!&can_select_ip6()) {
# User isn't allowed to select v6 address
print &ui_table_row($text{'edit_ip6'},
$access{'ipfollow'} && $parentdom ? $parentdom->{'ip6'} :
$config{'ip6enabled'} && $defip6 ? $defip6 :
$text{'edit_virt6off'});
}
else {
# Can select addres or allocate one
print &ui_table_row(&hlink($text{'form_iface6'}, "iface6"),
&virtual_ip6_input(\@cantmpls, $resel, 0,
$config{'ip6enabled'} ? 0 : -2),
undef, \@tds);
}
# Show DNS IP address field
if (&can_dnsip()) {
my $def_dns_ip =
&get_any_external_ip_address_cached() ||
&get_any_external_ip_address() || &get_dns_ip($resel);
my $dns_ip = $parentdom ? $parentdom->{'dns_ip'} : undef;
my @opts;
if ($def_dns_ip) {
push(@opts, [ 1, $text{'spf_default3'}, $def_dns_ip ]);
push(@opts, [ 2, $text{'spf_default2'} ]);
}
else {
push(@opts, [ 1, $text{'spf_default2'} ]);
}
push(@opts, [ 0, $text{'spf_custom'},
&ui_textbox("dns_ip", $dns_ip, 20) ]);
print &ui_table_row(&hlink($text{'edit_dnsip'}, "edit_dnsip"),
&ui_radio_table("dns_ip_def", $dns_ip ? 0 : 1, \@opts));
}
print &ui_hidden_table_end();
if ($can_website && !$aliasdom && $virtualmin_pro &&
$deftmpl->{'content_web'} == 3) {
# Show field for initial content
print &ui_hidden_table_start($text{'form_park'}, "width=100%", 2,
"park", 0);
# Initial content
print &ui_table_row(&hlink($text{'form_content'},"form_content"),
&ui_radio("content_def", 2,
[ [ 1, $text{'form_content1'} ],
[ 2, $text{'form_content2'} ],
[ 0, $text{'form_content0'} ] ])."<br>".
&ui_textarea("content", undef, 5, 70),
3, \@tds);
print &ui_hidden_table_end();
}
print &ui_form_end([ [ "ok", $text{'form_ok'} ] ]);
if (!$config{'template_auto'}) {
print "<script data-nocache>select_template($deftmpl->{'id'});</script>\n";
}
if (!$parentdom) {
print "<script data-nocache>select_plan($defplan->{'id'});</script>\n";
}
&ui_print_footer("", $text{'index_return'});