Handle hostnames with upper-case letters
[webmin.git] / link / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Redirect to another URL
4
5 BEGIN { push(@INC, ".."); };
6 use WebminCore;
7 &init_config();
8 %access = &get_module_acl();
9 $url = $access{'link'} || $config{'link'};
10 $host = $ENV{'HTTP_HOST'};
11 $host =~ s/:.*$//;
12 $url =~ s/\$\{REMOTE_USER\}/$remote_user/g ||
13         $url =~ s/\$REMOTE_USER/$remote_user/g;
14 $url =~ s/\$\{HTTP_HOST\}/$host/g ||
15         $url =~ s/\$HTTP_HOST/$host/g;
16 if (($url =~ /\$VIRTUALSERVER_/ || $url =~ /\$\{VIRTUALSERVER_/) &&
17     &foreign_check("virtual-server")) {
18         &foreign_require("virtual-server", "virtual-server-lib.pl");
19         $dom = &virtual_server::get_domain_by("user", $remote_user,
20                                               "parent", "");
21         if ($dom) {
22                 foreach $k (keys %$dom) {
23                         $uck = "VIRTUALSERVER_".uc($k);
24                         $url =~ s/\$\{$uck\}/$dom->{$k}/g ||
25                                 $url =~ s/\$$uck/$dom->{$k}/g;
26                         }
27                 }
28         else {
29                 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
30                 &error($text{'index_evirtualmin'});
31                 }
32         }
33 if ($url && $config{'immediate'}) {
34         &redirect($url);
35         }
36 else {
37         # Show a link page
38         &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
39         if ($url) {
40                 $desc = $access{'desc'} || $config{'desc'} ||
41                         "Open URL $url";
42                 $target = $config{'window'} ? "target=$module_name" : "";
43                 print "<font size=+1><a href='$url' $target>$desc</a></font><p>\n";
44                 }
45         else {
46                 print &text('index_econfig', "../config.cgi?$module_name"),"<p>\n";
47                 }
48         &ui_print_footer("/", $text{'index'});
49         }
50