forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cgi
executable file
·180 lines (166 loc) · 5.62 KB
/
index.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
#!/usr/local/bin/perl
# Display all Webmin modules visible to the current user
BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
&ReadParse();
$hostname = &get_display_hostname();
$ver = &get_webmin_version();
&get_miniserv_config(\%miniserv);
if ($gconfig{'real_os_type'}) {
if ($gconfig{'os_version'} eq "*") {
$ostr = $gconfig{'real_os_type'};
}
else {
$ostr = "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
}
}
else {
$ostr = "$gconfig{'os_type'} $gconfig{'os_version'}";
}
%access = &get_module_acl();
# Build a list of all modules
@modules = &get_visible_module_infos();
if (!defined($in{'cat'})) {
# Maybe redirect to some module after login
local $goto = &get_goto_module(\@modules);
if ($goto) {
&redirect($goto->{'dir'}.'/');
exit;
}
}
$gconfig{'sysinfo'} = 0 if ($gconfig{'sysinfo'} == 1);
if ($gconfig{'texttitles'}) {
@args = ( $text{'main_title2'}, undef );
}
else {
@args = ( $gconfig{'nohostname'} ? $text{'main_title2'} :
&text('main_title', $ver, $hostname, $ostr),
"images/webmin-blue.png" );
if ($gconfig{'showlogin'}) {
$args[0] = $remote_user." : ".$args[0];
}
}
&header(@args, undef, undef, 1, 1,
$tconfig{'brand'} ?
"<a href=$tconfig{'brand_url'}>$tconfig{'brand'}</a>" :
$gconfig{'brand'} ?
"<a href=$gconfig{'brand_url'}>$gconfig{'brand'}</a>" :
"<a href=http://www.webmin.com/>$text{'main_homepage'}</a>"
);
print "<center><font size=+1>",
&text('main_version', $ver, $hostname, $ostr),"</font></center>\n"
if (!$gconfig{'nohostname'});
print "<hr id='header_hr'><p>\n";
print $text{'main_header'};
if (!@modules) {
# use has no modules!
print "<p class='main_none'><b>$text{'main_none'}</b><p>\n";
}
elsif ($gconfig{"notabs_${base_remote_user}"} == 2 ||
$gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}) {
# Generate main menu with all modules on one page
print "<center><table id='mods' cellpadding=5 cellspacing=0 width=100%>\n";
$pos = 0;
$cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
$per = 100.0 / $cols;
foreach $m (@modules) {
if ($pos % $cols == 0) { print "<tr $cb>\n"; }
print "<td valign=top align=center width=$per\%>\n";
local $idx = $m->{'index_link'};
print "<table border><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
"<img src=$m->{'dir'}/images/icon.gif border=0 ",
"width=48 height=48></a></td></tr></table>\n";
print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
if ($pos % $cols == $cols - 1) { print "</tr>\n"; }
$pos++;
}
print "</table></center><p><hr id='mods_hr'>\n";
}
else {
# Display under categorised tabs
&ReadParse();
%cats = &list_categories(\@modules);
@cats = sort { $b cmp $a } keys %cats;
$cats = @cats;
$per = $cats ? 100.0 / $cats : 100;
if (!defined($in{'cat'})) {
# Use default category
if (defined($gconfig{'deftab'}) &&
&indexof($gconfig{'deftab'}, @cats) >= 0) {
$in{'cat'} = $gconfig{'deftab'};
}
else {
$in{'cat'} = $cats[0];
}
}
elsif (!$cats{$in{'cat'}}) {
$in{'cat'} = "";
}
print "<table id='cattabs' border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
$usercol = defined($gconfig{'cs_header'}) ||
defined($gconfig{'cs_table'}) ||
defined($gconfig{'cs_page'});
foreach $c (@cats) {
$t = $cats{$c};
if ($in{'cat'} eq $c) {
print "<td class='usercoll' valign=top $cb>", $usercol ? "<br>" :
"<img src=images/lc2.gif alt=\"\">","</td>\n";
print "<td class='usercolc' id='selectedcat' $cb> <b>$t</b> </td>\n";
print "<td class='usercolr' valign=top $cb>", $usercol ? "<br>" :
"<img src=images/rc2.gif alt=\"\">","</td>\n";
}
else {
print "<td class='usercoll' valign=top $tb>", $usercol ? "<br>" :
"<img src=images/lc1.gif alt=\"\">","</td>\n";
print "<td class='usercolc' $tb> ",
"<a href=$gconfig{'webprefix'}/?cat=$c><b>$t</b></a> </td>\n";
print "<td class='usercolr' valign=top $tb>", $usercol ? "<br>" :
"<img src=images/rc1.gif alt=\"\">","</td>\n";
}
print "<td width=10></td>\n";
}
print "</tr></table> <table id='mods' border=0 cellpadding=0 cellspacing=0 ",
"width=100% $cb>\n";
print "<tr><td><table width=100% cellpadding=5>\n";
# Display the modules in this category
$pos = 0;
$cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
$per = 100.0 / $cols;
foreach $m (@modules) {
next if ($m->{'category'} ne $in{'cat'});
if ($pos % $cols == 0) { print "<tr>\n"; }
local $idx = $m->{'index_link'};
print "<td valign=top align=center width=$per\%>\n";
print "<table border bgcolor=#ffffff><tr><td><a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>",
"<img src=$m->{'dir'}/images/icon.gif alt=\"\" border=0></a>",
"</td></tr></table>\n";
print "<a href=$gconfig{'webprefix'}/$m->{'dir'}/$idx>$m->{'desc'}</a></td>\n";
if ($pos++ % $cols == $cols - 1) { print "</tr>\n"; }
}
while($pos++ % $cols) {
print "<td width=$per\%></td>\n";
}
print "</table></td></tr></table><p><hr id='mods_hr'>\n";
}
# Check for incorrect OS
if (&foreign_check("webmin")) {
&foreign_require("webmin", "webmin-lib.pl");
&webmin::show_webmin_notifications();
}
if ($miniserv{'logout'} &&
!$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && !$ENV{'ANONYMOUS_USER'} &&
$ENV{'HTTP_USER_AGENT'} !~ /webmin/i) {
print "<table id='altlogout' width=100% cellpadding=0 cellspacing=0><tr>\n";
if ($main::session_id) {
print "<td align=right><a href='session_login.cgi?logout=1'>",
"$text{'main_logout'}</a></td>\n";
}
else {
print "<td align=right><a href=switch_user.cgi>",
"$text{'main_switch'}</a></td>\n";
}
print "</tr></table>\n";
}
print $text{'main_footer'};
&footer();