3 # Display a menu for some specific virtual server, or the default server
5 require './apache-lib.pl';
7 ($conf, $v) = &get_virtual_config($in{'virt'});
8 &can_edit_virt($v) || &error($text{'virt_ecannot'});
9 $desc = &text('virt_header', &virtual_name($v));
10 &ui_print_header($desc, $text{'virt_title'}, "", undef, undef, undef, undef, &restart_button());
12 # Display header and icons
13 $sw_icon = { "icon" => "images/show.gif",
14 "name" => $text{'virt_show'},
15 "link" => "show.cgi?virt=$in{'virt'}" };
16 if ($in{'virt'} && $access{'types'} eq '*') {
17 $ed_icon = { "icon" => "images/edit.gif",
18 "name" => $text{'virt_edit'},
19 "link" => "manual_form.cgi?virt=$in{'virt'}" };
21 &config_icons("virtual", "edit_virt.cgi?virt=$in{'virt'}&", $sw_icon,
22 $ed_icon ? $ed_icon : ());
24 # Display per-directory options
25 @dir = ( &find_directive_struct("Directory", $conf) ,
26 &find_directive_struct("DirectoryMatch", $conf),
27 &find_directive_struct("Files", $conf),
28 &find_directive_struct("FilesMatch", $conf),
29 &find_directive_struct("Location", $conf),
30 &find_directive_struct("LocationMatch", $conf),
31 &find_directive_struct("Proxy", $conf) );
34 print &ui_subheading($text{'dir_title'});
36 $what = &dir_name($d);
37 substr($what, 0, 1) = uc(substr($what, 0, 1));
38 push(@links, "dir_index.cgi?idx=".&indexof($d, @$conf).
41 push(@icons, "images/dir.gif");
42 push(@types, $d->{'name'});
44 if ($config{'show_list'}) {
46 print &ui_columns_start([ $text{'virt_path'},
47 $text{'virt_type'} ]);
48 for($i=0; $i<@links; $i++) {
49 print &ui_columns_row([
50 "<a href='$links[$i]'>$titles[$i]</a>",
51 $text{'virt_'.$types[$i]} ]);
53 print &ui_columns_end();
57 &icons_table(\@links, \@titles, \@icons, 3);
62 # Show form to create a dir
63 print &ui_form_start("create_dir.cgi", "post");
64 print &ui_hidden("virt", $in{'virt'});
65 print &ui_table_start($text{'virt_adddir'}, undef, 2);
67 print &ui_table_row($text{'virt_type'},
68 &ui_select("type", undef,
69 [ map { [ $_, $text{'virt_'.$_} ] }
70 $httpd_modules{'core'} >= 2.0 ?
71 ( "Directory", "Files", "Location", "Proxy" ) :
72 $httpd_modules{'core'} >= 1.2 ?
73 ( "Directory", "Files", "Location" ) :
74 ( "Directory", "Location" ) ]));
76 if ($httpd_modules{'core'} >= 1.2) {
77 print &ui_table_row($text{'virt_regexp'},
78 &ui_radio("regexp", 0, [ [ 0, $text{'virt_exact'} ],
79 [ 1, $text{'virt_re'} ] ]));
82 print &ui_table_row($text{'virt_path'},
83 &ui_textbox("path", undef, 50));
85 print &ui_table_end();
86 print &ui_form_end([ [ "", $text{'create'} ] ]);
88 if ($in{'virt'} && $access{'vaddr'}) {
89 # Show form for changing virtual server
91 print &ui_form_start("save_vserv.cgi");
92 print &ui_hidden("virt", $in{'virt'});
93 print &ui_table_start($text{'virt_opts'}, undef, 2);
99 if ($val =~ /^\[(\S+)\]:(\d+)$/) {
100 # IPv6 address and port
101 $addr = $1; $port = $2;
103 elsif ($val =~ /^\[(\S+)\]$/) {
107 elsif ($val =~ /^(\S+):(\d+)$/) {
108 # IPv4 address or hostname and port
109 $addr = $1; $port = $2;
112 # IPv4 address or hostname
117 # Multiple addresses and ports
118 print &ui_table_row($text{'vserv_addrs'},
119 &ui_textarea("addrs", join("\n", split(/\s+/, $addrs)),
124 print &ui_table_row($text{'vserv_addr'},
125 &ui_radio("addr_def", $addr eq "_default_" ? 1 :
126 $addr eq "*" ? 2 : 0,
127 [ [ 1, $text{'vserv_addr1'} ],
128 [ 2, $text{'vserv_any'} ],
129 [ 0, &ui_textbox("addr",
130 $addr eq "*" || $addr eq "_default_" ?
131 "" : $addr, 40) ] ]));
133 print &ui_table_row($text{'vserv_port'},
134 &choice_input($port eq "*" ? 1 : $port > 0 ? 2 : 0,
135 "port_mode", "0", "$text{'vserv_default'},0",
136 "$text{'vserv_any'},1", ",2").
137 &ui_textbox("port", $port > 0 ? $port : "", 5));
141 $root = &find_directive_struct("DocumentRoot", $v->{'members'});
142 print &ui_table_row($text{'vserv_root'},
143 &opt_input($root->{'words'}->[0], "root",
144 $text{'vserv_default'}, 50).
145 &file_chooser_button("root", 1, 1));
146 print &ui_hidden("old_root", $root->{'words'}->[0]);
149 $name = &find_directive("ServerName", $v->{'members'});
150 print &ui_table_row($text{'vserv_name'},
151 &opt_input($name, "name", $text{'vserv_default'}, 30));
153 print &ui_table_end();
154 print &ui_form_end([ [ undef, $text{'save'} ],
155 [ "delete", $text{'delete'} ] ]);
158 &ui_print_footer("", $text{'index_return'});