Handle hostnames with upper-case letters
[webmin.git] / webmin / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a table of icons for different types of webmin configuration
4
5 use strict;
6 use warnings;
7 require './webmin-lib.pl';
8 our (%in, %text, %gconfig, %config);
9 my $ver = &get_webmin_version();
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
11         undef, undef, undef, &text('index_version', $ver));
12 my %access = &get_module_acl();
13 &ReadParse();
14
15 my (@wlinks, @wtitles, @wicons);
16 @wlinks = ( "edit_access.cgi", "edit_bind.cgi", "edit_log.cgi",
17             "edit_proxy.cgi", "edit_ui.cgi", "edit_mods.cgi",
18             "edit_os.cgi", "edit_lang.cgi", "edit_startpage.cgi",
19             "edit_upgrade.cgi", "edit_session.cgi", "edit_assignment.cgi",
20             "edit_categories.cgi", "edit_descs.cgi", "edit_themes.cgi",
21             "edit_referers.cgi", "edit_anon.cgi", "edit_lock.cgi",
22             "edit_mobile.cgi", "edit_blocked.cgi", "edit_status.cgi",
23             "edit_advanced.cgi", "edit_debug.cgi", "edit_web.cgi", );
24 @wtitles = ( $text{'access_title'}, $text{'bind_title'},
25              $text{'log_title'}, $text{'proxy_title'},
26              $text{'ui_title'}, $text{'mods_title'},
27              $text{'os_title'}, $text{'lang_title'},
28              $text{'startpage_title'}, $text{'upgrade_title'},
29              $text{'session_title'}, $text{'assignment_title'},
30              $text{'categories_title'}, $text{'descs_title'},
31              $text{'themes_title'}, $text{'referers_title'},
32              $text{'anon_title'}, $text{'lock_title'},
33              $text{'mobile_title'}, $text{'blocked_title'},
34              $text{'status_title'}, $text{'advanced_title'},
35              $text{'debug_title'}, $text{'web_title'}, );
36 @wicons = ( "images/access.gif", "images/bind.gif", "images/log.gif",
37             "images/proxy.gif", "images/ui.gif", "images/mods.gif",
38             "images/os.gif", "images/lang.gif", "images/startpage.gif",
39             "images/upgrade.gif", "images/session.gif",
40             "images/assignment.gif", "images/categories.gif",
41             "images/descs.gif", "images/themes.gif", "images/referers.gif",
42             "images/anon.gif", "images/lock.gif", "images/mobile.gif",
43             "images/blocked.gif", "images/status.gif",
44             "images/advanced.gif", "images/debug.gif", "images/web.gif", );
45 if ($gconfig{'eazel'}) {
46         push(@wlinks, "edit_syslet.cgi");
47         push(@wtitles, $text{'syslet_title'});
48         push(@wicons, "images/syslet.gif");
49         }
50 if (&foreign_check("mailboxes")) {
51         push(@wlinks, "edit_sendmail.cgi");
52         push(@wtitles, $text{'sendmail_title'});
53         push(@wicons, "images/sendmail.gif");
54         }
55 push(@wlinks, "edit_ssl.cgi", "edit_ca.cgi");
56 push(@wtitles, $text{'ssl_title'}, $text{'ca_title'});
57 push(@wicons, "images/ssl.gif", "images/ca.gif");
58
59 # Hide dis-allowed pages
60 my %allow = map { $_, 1 } split(/\s+/, $access{'allow'});
61 my %disallow = map { $_, 1 } split(/\s+/, $access{'disallow'});
62 for(my $i=0; $i<@wlinks; $i++) {
63         $wlinks[$i] =~ /edit_(\S+)\.cgi/;
64         if (%allow && !$allow{$1} ||
65             $disallow{$1} ||
66             $1 eq "webmin" && $gconfig{'os_type'} eq 'windows') {
67                 splice(@wlinks, $i, 1);
68                 splice(@wtitles, $i, 1);
69                 splice(@wicons, $i, 1);
70                 $i--;
71                 }
72         }
73 &icons_table(\@wlinks, \@wtitles, \@wicons);
74
75 print &ui_hr();
76
77 print &ui_buttons_start();
78
79 my %miniserv;
80 &get_miniserv_config(\%miniserv);
81
82 if (&foreign_check("init")) {
83         &foreign_require("init", "init-lib.pl");
84         my $starting = &init::action_status("webmin");
85         print &ui_buttons_row("bootup.cgi",
86               $text{'index_boot'},
87               $text{'index_bootmsg'}.
88               ($miniserv{'inetd'} ? "<b>$text{'index_inetd'}</b>" :
89                !$ENV{'MINISERV_CONFIG'} ? "<b>$text{'index_apache'}</b>" : ""),
90               &ui_hidden("starting", $starting),
91               &ui_radio("boot", $starting == 2 ? 1 : 0,
92                         [ [ 1, $text{'yes'} ],
93                           [ 0, $text{'no'} ] ]));
94         }
95
96 # Restart Webmin
97 if (!$miniserv{'inetd'} && $ENV{'MINISERV_CONFIG'}) {
98         print &ui_buttons_row("restart.cgi",
99                       $text{'index_restart'}, $text{'index_restartmsg'});
100         }
101
102 # Submit OS info
103 if (!$config{'submitted'}) {
104         print &ui_buttons_row("submit.cgi",
105                       $text{'index_submit'}, $text{'index_submitmsg'});
106         }
107
108 # Refresh modules
109 print &ui_buttons_row("refresh_modules.cgi",
110               $text{'index_refresh'}, $text{'index_refreshmsg'});
111
112 print &ui_buttons_end();
113
114 if ($in{'refresh'} && defined(&theme_post_change_modules)) {
115         # Refresh left menu
116         &theme_post_change_modules();
117         }
118
119 &ui_print_footer("/", $text{'index'});
120