Handle hostnames with upper-case letters
[webmin.git] / msctheme-enhanced / theme.pl
1 #!/usr/local/bin/perl
2
3 #theme_prebody - called just before the main body of every page, so it can print any HTML it likes.
4 #theme_postbody - called just after the main body of every page.
5 #theme_header - called instead of the normal header function, with the same parameters. You could use this to re-write the header function in your own style with help and index links whereever you want them.
6 #theme_footer - called instead of the footer function with the same parameters.
7 #theme_error - called instead of the error function, with the same parameters.
8
9 %letter_sizes = (
10         '100.gif', [ 10, 16 ],
11         '101.gif', [ 11, 16 ],
12         '102.gif', [ 6, 16 ],
13         '103.gif', [ 10, 16 ],
14         '104.gif', [ 9, 16 ],
15         '105.gif', [ 4, 16 ],
16         '106.gif', [ 5, 16 ],
17         '107.gif', [ 9, 16 ],
18         '108.gif', [ 4, 16 ],
19         '109.gif', [ 14, 16 ],
20         '110.gif', [ 9, 16 ],
21         '111.gif', [ 11, 16 ],
22         '112.gif', [ 10, 16 ],
23         '113.gif', [ 10, 16 ],
24         '114.gif', [ 6, 16 ],
25         '115.gif', [ 8, 16 ],
26         '116.gif', [ 6, 16 ],
27         '117.gif', [ 9, 16 ],
28         '118.gif', [ 10, 16 ],
29         '119.gif', [ 13, 16 ],
30         '120.gif', [ 10, 16 ],
31         '121.gif', [ 10, 16 ],
32         '122.gif', [ 8, 16 ],
33         '123.gif', [ 7, 16 ],
34         '124.gif', [ 4, 16 ],
35         '125.gif', [ 7, 16 ],
36         '126.gif', [ 9, 16 ],
37         '177.iso-8859-2.gif', [ 10, 16 ],
38         '179.iso-8859-2.gif', [ 7, 16 ],
39         '182.iso-8859-2.gif', [ 9, 16 ],
40         '188.iso-8859-2.gif', [ 9, 16 ],
41         '191.iso-8859-2.gif', [ 9, 16 ],
42         '192.gif', [ 12, 16 ],
43         '193.gif', [ 12, 16 ],
44         '194.gif', [ 11, 16 ],
45         '195.gif', [ 12, 16 ],
46         '196.gif', [ 12, 16 ],
47         '197.gif', [ 12, 16 ],
48         '198.gif', [ 13, 16 ],
49         '199.gif', [ 12, 16 ],
50         '200.gif', [ 7, 16 ],
51         '201.gif', [ 8, 16 ],
52         '202.gif', [ 8, 16 ],
53         '203.gif', [ 7, 16 ],
54         '204.gif', [ 6, 16 ],
55         '205.gif', [ 5, 16 ],
56         '206.gif', [ 7, 16 ],
57         '207.gif', [ 7, 16 ],
58         '208.gif', [ 11, 16 ],
59         '208.iso-8859-9.gif', [ 13, 16 ],
60         '209.gif', [ 10, 16 ],
61         '210.gif', [ 13, 16 ],
62         '211.gif', [ 13, 16 ],
63         '211.iso-8859-2.gif', [ 13, 16 ],
64         '212.gif', [ 12, 16 ],
65         '213.gif', [ 13, 16 ],
66         '214.gif', [ 13, 16 ],
67         '214.iso-8859-9.gif', [ 13, 16 ],
68         '215.gif', [ 9, 16 ],
69         '216.gif', [ 13, 16 ],
70         '217.gif', [ 9, 16 ],
71         '218.gif', [ 9, 16 ],
72         '219.gif', [ 9, 16 ],
73         '220.gif', [ 9, 16 ],
74         '220.iso-8859-9.gif', [ 9, 16 ],
75         '221.gif', [ 11, 16 ],
76         '221.iso-8859-9.gif', [ 5, 16 ],
77         '222.gif', [ 9, 16 ],
78         '222.iso-8859-9.gif', [ 11, 16 ],
79         '223.gif', [ 9, 16 ],
80         '224.gif', [ 10, 16 ],
81         '225.gif', [ 10, 16 ],
82         '226.gif', [ 11, 16 ],
83         '227.gif', [ 10, 16 ],
84         '228.gif', [ 10, 16 ],
85         '229.gif', [ 11, 16 ],
86         '230.gif', [ 16, 16 ],
87         '230.iso-8859-2.gif', [ 9, 16 ],
88         '231.gif', [ 10, 16 ],
89         '231.iso-8859-9.gif', [ 10, 16 ],
90         '231.iso.8859-9.gif', [ 10, 16 ],
91         '232.gif', [ 11, 16 ],
92         '233.gif', [ 11, 16 ],
93         '234.gif', [ 11, 16 ],
94         '234.iso-8859-2.gif', [ 9, 16 ],
95         '235.gif', [ 11, 16 ],
96         '236.gif', [ 6, 16 ],
97         '237.gif', [ 6, 16 ],
98         '238.gif', [ 6, 16 ],
99         '239.gif', [ 7, 16 ],
100         '240.gif', [ 10, 16 ],
101         '240.iso-8859-9.gif', [ 10, 16 ],
102         '241.gif', [ 9, 16 ],
103         '241.iso-8859-2.gif', [ 9, 16 ],
104         '242.gif', [ 11, 16 ],
105         '243.gif', [ 11, 16 ],
106         '243.iso-8859-2.gif', [ 11, 16 ],
107         '244.gif', [ 11, 16 ],
108         '245.gif', [ 11, 16 ],
109         '246.gif', [ 11, 16 ],
110         '246.iso-8859-9.gif', [ 11, 16 ],
111         '247.gif', [ 9, 16 ],
112         '248.gif', [ 10, 16 ],
113         '249.gif', [ 9, 16 ],
114         '250.gif', [ 9, 16 ],
115         '251.gif', [ 9, 16 ],
116         '252.gif', [ 9, 16 ],
117         '252.iso-8859-9.gif', [ 9, 16 ],
118         '253.gif', [ 10, 16 ],
119         '253.iso-8859-9.gif', [ 5, 16 ],
120         '254.gif', [ 10, 16 ],
121         '255.gif', [ 9, 16 ],
122         '32.gif', [ 6, 16 ],
123         '33.gif', [ 4, 16 ],
124         '34.gif', [ 7, 16 ],
125         '35.gif', [ 9, 16 ],
126         '36.gif', [ 8, 16 ],
127         '37.gif', [ 13, 16 ],
128         '38.gif', [ 11, 16 ],
129         '39.gif', [ 3, 16 ],
130         '40.gif', [ 6, 16 ],
131         '41.gif', [ 6, 16 ],
132         '42.gif', [ 7, 16 ],
133         '43.gif', [ 9, 16 ],
134         '44.gif', [ 4, 16 ],
135         '45.gif', [ 6, 16 ],
136         '46.gif', [ 4, 16 ],
137         '47.gif', [ 7, 16 ],
138         '48.gif', [ 9, 16 ],
139         '49.gif', [ 6, 16 ],
140         '50.gif', [ 9, 16 ],
141         '51.gif', [ 9, 16 ],
142         '52.gif', [ 10, 16 ],
143         '53.gif', [ 9, 16 ],
144         '54.gif', [ 10, 16 ],
145         '55.gif', [ 8, 16 ],
146         '56.gif', [ 9, 16 ],
147         '57.gif', [ 10, 16 ],
148         '58.gif', [ 5, 16 ],
149         '59.gif', [ 4, 16 ],
150         '60.gif', [ 9, 16 ],
151         '61.gif', [ 10, 16 ],
152         '62.gif', [ 10, 16 ],
153         '63.gif', [ 9, 16 ],
154         '64.gif', [ 12, 16 ],
155         '65.gif', [ 12, 16 ],
156         '66.gif', [ 9, 16 ],
157         '67.gif', [ 12, 16 ],
158         '68.gif', [ 10, 16 ],
159         '69.gif', [ 7, 16 ],
160         '70.gif', [ 7, 16 ],
161         '71.gif', [ 13, 16 ],
162         '72.gif', [ 9, 16 ],
163         '73.gif', [ 5, 16 ],
164         '74.gif', [ 8, 16 ],
165         '75.gif', [ 9, 16 ],
166         '76.gif', [ 8, 16 ],
167         '77.gif', [ 12, 16 ],
168         '78.gif', [ 10, 16 ],
169         '79.gif', [ 12, 16 ],
170         '80.gif', [ 9, 16 ],
171         '81.gif', [ 13, 16 ],
172         '82.gif', [ 9, 16 ],
173         '83.gif', [ 9, 16 ],
174         '84.gif', [ 8, 16 ],
175         '85.gif', [ 9, 16 ],
176         '86.gif', [ 11, 16 ],
177         '87.gif', [ 14, 16 ],
178         '88.gif', [ 11, 16 ],
179         '89.gif', [ 11, 16 ],
180         '90.gif', [ 9, 16 ],
181         '91.gif', [ 5, 16 ],
182         '93.gif', [ 6, 16 ],
183         '94.gif', [ 9, 16 ],
184         '95.gif', [ 9, 16 ],
185         '96.gif', [ 6, 16 ],
186         '97.gif', [ 11, 16 ],
187         '98.gif', [ 10, 16 ],
188         '99.gif', [ 10, 16 ]
189         );
190
191 sub theme_header {
192
193 local @available = ("webmin", "system", "servers", "cluster", "hardware", "", "net", "kororaweb");
194
195 local $ll;
196 local %access = &get_module_acl();
197 local %gaccess = &get_module_acl(undef, "");
198 print "<!doctype html public \"-//W3C//DTD HTML 3.2 Final//EN\">\n";
199 print "<html>\n";
200 local $os_type = $gconfig{'real_os_type'} ? $gconfig{'real_os_type'}
201                       : $gconfig{'os_type'};
202 local $os_version = $gconfig{'real_os_version'} ? $gconfig{'real_os_version'}
203                             : $gconfig{'os_version'};
204 print "<head>\n";
205 if ($charset) {
206     print "<meta http-equiv=\"Content-Type\" ",
207           "content=\"text/html; Charset=$charset\">\n";
208     }
209 print "<link rel='icon' href='/images/webmin_icon.png' type='image/png'>\n";
210 if (@_ > 0) {
211     if ($gconfig{'sysinfo'} == 1) {
212         printf "<title>%s : %s on %s (%s %s)</title>\n",
213             $_[0], $remote_user, &get_system_hostname(),
214             $os_type, $os_version;
215         }
216     else {
217         print "<title>$_[0]</title>\n";
218         }
219     print $_[7] if ($_[7]);
220     if ($gconfig{'sysinfo'} == 0 && $remote_user) {
221         print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
222         printf
223         "defaultStatus=\"%s%s logged into %s %s on %s (%s %s)\";\n",
224             $ENV{'ANONYMOUS_USER'} ? "Anonymous user" : $remote_user,
225             $ENV{'SSL_USER'} ? " (SSL certified)" :
226             $ENV{'LOCAL_USER'} ? " (Local user)" : "",
227             $text{'programname'},
228             &get_webmin_version(), &get_system_hostname(),
229             $os_type, $os_version;
230
231 #########JAVA & CSS FOR MENUS START###########
232 print qq~
233    var r;
234    var menuLive;
235    var shouldSet;
236    var image_name;
237    var image_over;
238    var image_out;
239
240    function showMenu(cat) {
241      if (menuLive) {
242        if (r) {
243            r.style.display='none'
244        }
245        r = document.getElementById(cat)
246        r.style.display=''
247      }
248    }
249
250    function setLive() {
251        if (menuLive) {
252           menuLive ='' 
253           hideMenu()
254        } else {
255           menuLive = '1'
256        }
257    }
258
259    function hideMenu() {
260       if (r) {
261          r.style.display='none'
262       }
263    }
264
265  
266    function mouseover(image_name, image_over) {
267       this.document[image_name].src= image_over;
268    }
269  
270    function mouseout(image_name, image_out) {
271       this.document[image_name].src=image_out;
272    }
273
274
275 </script>
276                                                                                 
277 <style type="text/css">
278 div.menucontainer {
279     padding: 2px 2px;
280     border: 1px groove gray;
281     background: lightgrey;
282     border-width: 2px;
283     position: absolute;
284 }
285
286 div.menu a  {
287     font: 1em sans-serif;
288     text-decoration: none;
289 }
290
291 div.menu {
292     border-bottom: 1px solid silver;
293 }
294
295 div.menu div:hover {
296     color: white;
297     background: grey;
298 }
299
300
301 div.title_menu {
302     border-bottom: 1px solid silver;
303     font: 1em sans-serif;
304     list-style-type: none;
305     background: black;
306     color: white;
307     font-weight: bold;
308 }
309
310 </style>
311 ~;
312 #########JAVA & CSS FOR MENUS STOP###########
313
314         }
315     }
316
317 @msc_modules = &get_available_module_infos()
318         if (!scalar(@msc_modules));
319
320 print "</head>\n";
321 if ($theme_no_table) {
322         print '<body bgcolor=#6696bc link=#000000 vlink=#000000 text=#000000 leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" '.$_[8].'>';
323         }
324 else {
325         print '<body bgcolor=#6696bc link=#000000 vlink=#000000 text=#000000 leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" '.$_[8].'>';
326         }
327
328 if ($remote_user && @_ > 1) {
329         # Show basic header with webmin.com link and logout button
330         local $logout = $main::session_id ? "/session_login.cgi?logout=1"
331                                           : "/switch_user.cgi";
332         local $loicon = $main::session_id ? "logout.jpg" : "switch.jpg";
333         local $lowidth = $main::session_id ? 84 : 27;
334         local $lotext = $main::session_id ? $text{'main_logout'}
335                                           : $text{'main_switch'};
336         print qq~
337           <table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/top_bar/bg.jpg" height="32">
338           <tr>
339             <td width="4" nowrap><img src="/images/top_bar/left.jpg" width="4" height="32"></td>
340             <td width="100%" nowrap><a href="http://www.webmin.com"><img src="/images/top_bar/webmin_logo.jpg" width="99" height="32" border="0" alt="Webmin home page"></a></td>~;
341         if (!$ENV{'ANONYMOUS_USER'}) {
342                 if ($gconfig{'nofeedbackcc'} != 2 && $gaccess{'feedback'}) {
343                         print qq~<td><a href='/feedback_form.cgi?module=$module_name'><img src=/images/top_bar/feedback.jpg width=97 height=32 alt="$text{'main_feedback'}" border=0></a></td>~;
344                         }
345                 if (!$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} &&
346                     !$ENV{'HTTP_WEBMIN_SERVERS'}) {
347                         if ($gconfig{'nofeedbackcc'} != 2 &&
348                             $gaccess{'feedback'}) {
349                                 print qq~<td><img src=/images/top_bar/top_sep.jpg width=12 height=32></td>~;
350                                 }
351                         print qq~<td width="84" nowrap><a href='$logout'><img src="/images/top_bar/$loicon" height="31" width=$lowidth border="0" alt="$lotext"></a></td>~;
352                         }
353                 }
354         print qq~<td width="3" nowrap>
355               <div align="right"><img src="/images/top_bar/right.jpg" width="3" height="32"></div>
356             </td>
357           </tr>
358         </table>~;
359         }
360
361 local $one = @msc_modules == 1 && $gconfig{'gotoone'};
362 local $notabs = $gconfig{"notabs_${base_remote_user}"} == 2 ||
363         $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'};
364 if (@_ > 1 && !$one && $remote_user && !$notabs) {
365     # Display module categories
366     print qq~<table width="100%" border="0" cellspacing="0" cellpadding="0" height="7">
367   <tr>
368     <td background="/images/top_bar/shadow_bg.jpg" nowrap><img src="/images/top_bar/shadow.jpg" width="8" height="7"></td>
369   </tr>
370 </table>~;
371
372     local %catnames;
373     &read_file("$config_directory/webmin.catnames", \%catnames);
374     foreach $m (@msc_modules) {
375         local $c = $m->{'category'};
376         next if ($cats{$c});
377         if (defined($catnames{$c})) {
378             $cats{$c} = $catnames{$c};
379             }
380         elsif ($text{"category_$c"}) {
381             $cats{$c} = $text{"category_$c"};
382             }
383         else {
384             # try to get category name from module ..
385             local %mtext = &load_language($m->{'dir'});
386             if ($mtext{"category_$c"}) {
387                 $cats{$c} = $mtext{"category_$c"};
388                 }
389             else {
390                 $c = $m->{'category'} = "";
391                 $cats{$c} = $text{"category_$c"};
392                 }
393             }
394         }
395     @cats = sort { $b cmp $a } keys %cats;
396     $cats = @cats;
397     $per = $cats ? 100.0 / $cats : 100;
398
399     if ($theme_index_page) {
400             if (!defined($in{'cat'})) {
401                
402                 # Use default category
403                 if (defined($gconfig{'deftab'}) &&
404                     &indexof($gconfig{'deftab'}, @cats) >= 0) {
405                     $in{'cat'} = $gconfig{'deftab'};
406                     }
407                 else {
408                     $in{'cat'} = $cats[0];
409                     }
410                 }
411             elsif (!$cats{$in{'cat'}}) {
412                 $in{'cat'} = "";
413                 }
414     }
415
416 #####Navigation Bar START#####
417     print qq~<table width="100%" border="0" cellspacing="0" cellpadding="0" height="57" background="/images/nav/bg.jpg">
418   <tr background="/images/nav/bg.jpg">
419     <td width="6" nowrap><img src="/images/nav/left.jpg" width="3" height="57"></td>~;
420
421     foreach $c (@cats) {
422         local $t = $cats{$c};
423            $inlist    = "false";
424            foreach $testet (@available) {
425                if ($testet eq $c) {
426                 $inlist = "true";
427                } 
428             }
429         if ($in{'cat'} eq $c && $theme_index_page) {
430            if ($inlist eq "true") {
431
432               if ($c eq "") {
433
434 ###OTHER MENU [ACTIVE]
435
436                 print qq~<td nowrap><center><a href="/?cat=" onMouseOver="showMenu('other_menu');"><img src="/images/cats/other_over.jpg" alt="$t" width="43" height="44" border="0" name="other_image"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('other_menu');" onMouseOver="showMenu('other_menu');"><br><a href="/?cat=" onMouseOver="showMenu('other_menu');">~;
437
438             &chop_font;
439
440                 print "</a></center>";
441 &create_menu();
442                 print qq~</td>
443     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~; 
444               } elsif ($c eq "webmin") {
445
446 ###WEBMIN MENU [ACTIVE]
447
448                if (@_ > 1) {
449                 print qq~<td nowrap><center><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><img src="/images/cats/$c\_over.jpg" alt="$t" width="43" height="44" border="0"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('$c\_menu');" onMouseOver="if (menuLive) showMenu('$c\_menu');"><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><br>~;
450
451
452             &chop_font;
453                           print "</a></center>";
454 &create_menu();
455                           print qq~</td>
456     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~;
457                 } else {
458
459 ###UNKNOWN MENU [ACTIVE]
460
461                 print qq~<td nowrap><center><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><img src="/images/cats/unknown_over.jpg" alt="$t" width="43" height="44" border="0"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('$c\_menu');" onMouseOver="if (menuLive) showMenu('$c\_menu');"><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><br>~;
462                      &chop_font;
463                      print "</a></center>";
464 &create_menu();
465                      print qq~</td>
466     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~;
467                 }
468                } else {
469
470 ###REST OF MENUS [ACTIVE]
471
472                 print qq~<td nowrap><center><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><img src="/images/cats/$c\_over.jpg" alt="$t" width="43" height="44" border="0"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('$c\_menu');" onMouseOver="if (menuLive) showMenu('$c\_menu');"><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><br>~;
473
474             &chop_font;
475
476                print "</a></center>";
477 &create_menu();
478                print qq~</td>
479     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~;
480               }
481
482         } else {
483
484 ###UNKNOWN CATAGORY [ACTIVE]
485
486                 print qq~<td nowrap><center><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><img src="/images/cats/unknown_over.jpg" alt="$t" width="43" height="44" border="0"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('$c\_menu');" onMouseOver="if (menuLive) showMenu('$c\_menu');"><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu');"><br>~;
487
488             &chop_font;
489
490             print "</a></center>";
491 &create_menu();
492             print qq~</td>
493     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~;
494            }
495         }
496         else {
497             if ($inlist eq "true") {
498               if ($c eq "") {
499
500 ###OTHER MENU [NON-ACTIVE]
501
502                 print qq~<td nowrap><center><a href="/?cat=" onMouseOver="showMenu('other_menu'); mouseover('other_image','/images/cats/other_over.jpg');" onMouseOut="mouseout('other_image','/images/cats/other.jpg');"><img src="/images/cats/other.jpg" alt="$t" width="43" height="44" border="0" name="other_image"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('other_menu');" onMouseOver="showMenu('other_menu'); mouseover('other_image','/images/cats/other_over.jpg');" onMouseOut="mouseout('other_image','/images/cats/other.jpg');"><a href="/?cat=" onMouseOver="showMenu('other_menu'); mouseover('other_image','/images/cats/other_over.jpg');" onMouseOut="mouseout('other_image','/images/cats/other.jpg');"><br>~;
503
504
505             &chop_font;
506
507                 print "</a></center>";
508 &create_menu();
509                 print qq~</td>
510     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~; 
511               } else {
512
513 ###REST OF MENUS [NON-ACTIVE]
514                 print qq~<td nowrap><center><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu'); mouseover('$c\_image','/images/cats/$c\_over.jpg');" onMouseOut="mouseout('$c\_image','/images/cats/$c.jpg');"><img src="/images/cats/$c.jpg" alt="$t" width="43" height="44" border="0" name="$c\_image"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('$c\_menu');" onMouseOver="if (menuLive) showMenu('$c\_menu'); mouseover('$c\_image','/images/cats/$c\_over.jpg');" onMouseOut="mouseout('$c\_image','/images/cats/$c.jpg');"><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu'); mouseover('$c\_image','/images/cats/$c\_over.jpg');" onMouseOut="mouseout('$c\_image','/images/cats/$c.jpg');"><br>~;
515
516
517             &chop_font;
518
519                print "</a></center>";
520 &create_menu();
521                print qq~</td>
522     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~;
523               }
524         } else {
525
526 ###UNKNOWN CATAGORY [NON-ACTIVE]
527
528                 print qq~<td nowrap><center><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu'); mouseover('$c\_image','/images/cats/unknown_over.jpg');" onMouseOut="mouseout('$c\_image','/images/cats/unknown.jpg');"><img src="/images/cats/unknown.jpg" alt="$t" width="43" height="44" border="0" name="$c\_image"></a><img src="/images/list.gif" width="10" height="44" border="0" onClick="setLive(); showMenu('$c\_menu');" onMouseOver="if (menuLive) showMenu('$c\_menu'); mouseover('$c\_image','/images/cats/unknown_over.jpg');" onMouseOut="mouseout('$c\_image','/images/cats/unknown.jpg');"><a href="/?cat=$c" onMouseOver="if (menuLive) showMenu('$c\_menu'); mouseover('$c\_image','/images/cats/unknown_over.jpg');" onMouseOut="mouseout('$c\_image','/images/cats/unknown.jpg');"><br>~;
529
530             &chop_font;
531
532             print "</a></center>";
533 &create_menu();
534             print qq~</td>
535     <td width="17" nowrap><img src="/images/nav/sep.jpg" width="17" height="57"></td>~;
536         }
537            
538             }
539         }
540
541     print qq~<td width="100%" nowrap><div onClick="hideMenu(); if (menuLive) setLive();">&nbsp;</td>
542     <td nowrap>&nbsp;</td>
543   </tr>
544 </table>~;
545     print qq~<div onClick="hideMenu(); if (menuLive) setLive();"><table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/nav/bottom_bg.jpg" height="4">
546   <tr>
547     <td width="100%"><img src="/images/nav/bottom_left.jpg" width="3" height="4"></td>
548   </tr>
549 </table>~;
550    }
551
552 if (@_ > 1 && (!$_[5] || $ENV{'HTTP_WEBMIN_SERVERS'})) {
553    # Show tabs under module categories
554    print qq~<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/nav/bottom_shadow2.jpg"> <tr background="/images/nav/bottom_shadow2.jpg">~;
555
556    if ($gconfig{'sysinfo'} == 2 && $remote_user) {
557         &tab_start();
558         printf "%s%s logged into %s %s on %s (%s%s)</td>\n",
559                 $ENV{'ANONYMOUS_USER'} ? "Anonymous user" : "<tt>$remote_user</tt>",
560                 $ENV{'SSL_USER'} ? " (SSL certified)" :
561                 $ENV{'LOCAL_USER'} ? " (Local user)" : "",
562                 $text{'programname'},
563                 $version, "<tt>".&get_system_hostname()."</tt>",
564                 $os_type, $os_version eq "*" ? "" : " $os_version";
565         &tab_end();
566         }
567    if ($ENV{'HTTP_WEBMIN_SERVERS'}) {
568         &tab_start();
569         print "<a href='$ENV{'HTTP_WEBMIN_SERVERS'}'>",
570               "$text{'header_servers'}</a><br>\n";
571         &tab_end();
572         }
573         if ($notabs && !$_[5]) { 
574                 &tab_start;
575                 print "<a href='$gconfig{'webprefix'}/?cat=$module_info{'category'}'>$text{'header_webmin'}</a><br>\n";
576                 &tab_end;
577                 }
578         if (!$_[4]) {
579                 local $mi = $module_index_link ||
580                             $module_name ? "/$module_name/" : "/";
581                 &tab_start; print "<a href=\"$gconfig{'webprefix'}$mi\">",
582                             "$text{'header_module'}</a>"; &tab_end;
583                 }
584         if (ref($_[2]) eq "ARRAY" && !$ENV{'ANONYMOUS_USER'}) {
585                 &tab_start; print &hlink($text{'header_help'}, $_[2]->[0], $_[2]->[1]); &tab_end;
586                 }
587         elsif (defined($_[2]) && !$ENV{'ANONYMOUS_USER'}) {
588                 &tab_start; print &hlink($text{'header_help'}, $_[2]); &tab_end;
589                 }
590         if ($_[3]) {
591                 if (!$access{'noconfig'}) {
592                         &tab_start; print "<a href=\"/config.cgi?$module_name\">",
593                               $text{'header_config'},"</a>"; &tab_end;
594                         }
595                 }
596
597     foreach $t (split(/<br>/, $_[6])) {
598       if ($t =~ /\S/) {
599               &tab_start; print $t; &tab_end;
600       }
601     }
602
603 print qq~
604     <td nowrap width="100%" background="/images/nav/bottom_shadow2.jpg" valign="top">
605
606       <table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/nav/bottom_shadow2.jpg">
607         <tr>
608           <td><img src="/unauthenticated/nav/bottom_shadow.jpg" width="43" height="9"></td>
609         </tr>
610       </table>
611
612
613     </td>
614   </tr>
615 </table>~;
616
617     if (!$_[5]) {
618             # Show page title in tab
619             local $title = $_[0];
620             $title =~ s/&auml;/ä/g;
621             $title =~ s/&ouml;/ö/g;
622             $title =~ s/&uuml;/ü/g;
623             $title =~ s/&nbsp;/ /g;
624
625             print "<p><table border=0 cellpadding=0 cellspacing=0 width=95% align=center><tr><td><table border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
626             print "<td bgcolor=#bae3ff>",
627               "<img src=/images/tabs/blue_left.jpg width=13 height=22 ",
628               "alt=\"\">","</td>\n";
629             print "<td bgcolor=#bae3ff>&nbsp;<b>$title</b>&nbsp;</td>\n";
630             print "<td bgcolor=#bae3ff>",
631               "<img src=/images/tabs/blue_right.jpg width=19 height=22 ",
632               "alt=\"\">","</td>\n";
633             if ($_[9]) {
634                 print "</tr></table></td> <td align=right><table border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
635                 print "<td bgcolor=#bae3ff>",
636                       "<img src=/images/tabs/blue_left.jpg width=13 height=22 ",
637                       "alt=\"\">","</td>\n";
638                 print "<td bgcolor=#bae3ff>&nbsp;<b>$_[9]</b>&nbsp;</td>\n";
639                 print "<td bgcolor=#bae3ff>",
640                       "<img src=/images/tabs/blue_right.jpg width=19 height=22",
641                       " alt=\"\">","</td>\n";
642                 }
643             print "</tr></table></td></tr></table>"; 
644
645              &theme_prebody;
646         }
647     } elsif (@_ > 1) {
648             print qq~<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/unauthenticated/nav/bottom_shadow.jpg">
649           <tr>
650             <td width="100%" nowrap><img src="/unauthenticated/nav/bottom_shadow.jpg" width="43" height="9"></td>
651           </tr>
652         </table><br>~;
653     }
654 @header_arguments = @_;
655 }
656
657 sub theme_prebody
658 {
659 if ($theme_no_table) {
660         print "<ul>\n";
661         }
662 else {
663         #print "<table border=0 width=95% align=center cellspacing=0 cellpadding=0><tr><td background=/images/msctile2.jpg>\n";
664         print "<table border=0 width=95% align=center cellspacing=0 cellpadding=0><tr><td bgcolor=#ffffff>\n";
665         print "<table border=0 width=95% align=center cellspacing=0 cellpadding=0><tr><td>\n";
666         }
667 }
668
669 sub theme_footer {
670 local $i;
671
672 if ($theme_no_table) {
673         print "</ul>\n";
674         }
675 elsif (@header_arguments > 1 && !$header_arguments[5]) {
676         print "</table></table><br>\n";
677         }
678
679 print "<table border=0 width=100% align=center cellspacing=0 cellpadding=0 bgcolor=#6696bc><tr><td>\n";
680
681 for($i=0; $i+1<@_; $i+=2) {
682     local $url = $_[$i];
683     if ($url eq '/') {
684         $url = "/?cat=$module_info{'category'}";
685         }
686     elsif ($url eq '' && $module_name) {
687         $url = "/$module_name/";
688         }
689     elsif ($url =~ /^\?/ && $module_name) {
690         $url = "/$module_name/$url";
691         }
692     if ($i == 0) {
693         print "&nbsp;<a href=\"$url\"><img alt=\"<-\" align=middle border=0 src=/images/arrow.jpg></a>\n";
694         }
695     else {
696         print "&nbsp;|\n";
697         }
698     print "&nbsp;<a href=\"$url\">",&text('main_return', $_[$i+1]),"</a>\n";
699     }
700 print "</td></tr></table>\n";
701
702 print "<br>\n";
703 if (!$_[$i]) {
704     local $postbody = $tconfig{'postbody'};
705     if ($postbody) {
706         local $hostname = &get_system_hostname();
707         local $version = &get_webmin_version();
708         local $os_type = $gconfig{'real_os_type'} ?
709                 $gconfig{'real_os_type'} : $gconfig{'os_type'};
710         local $os_version = $gconfig{'real_os_version'} ?
711                 $gconfig{'real_os_version'} : $gconfig{'os_version'};
712         $postbody =~ s/%HOSTNAME%/$hostname/g;
713         $postbody =~ s/%VERSION%/$version/g;
714         $postbody =~ s/%USER%/$remote_user/g;
715         $postbody =~ s/%OS%/$os_type $os_version/g;
716         print "$postbody\n";
717         }
718     if ($tconfig{'postbodyinclude'}) {
719         open(INC, $module_name ?
720             "../$gconfig{'theme'}/$tconfig{'postbodyinclude'}" :
721             "$gconfig{'theme'}/$tconfig{'postbodyinclude'}");
722         while(<INC>) {
723             print;
724             }
725         close(INC);
726         }
727     if (defined(&theme_postbody)) {
728         &theme_postbody(@_);
729         }
730     print "</div></body></html>\n";
731     }
732
733 }
734
735 #sub theme_error {
736
737 #print "error";
738
739 #}
740
741
742 sub chop_font {
743
744 if (!$current_lang_info->{'titles'} || $gconfig{'texttitles'}) {
745         print $t;
746 } else {
747         foreach $l (split(//, $t)) {
748             $ll = ord($l);
749             local $gif;
750             if ($ll > 127 && $current_lang_info->{'charset'}) {
751                 $gif = "$ll.$current_lang_info->{'charset'}.gif";
752                 }
753             else {
754                 $gif = "$ll.gif";
755                 }
756             local $sz = $letter_sizes{$gif};
757             printf "<img src=/images/letters2/%s width=%d height=%d alt=\"%s\" align=bottom border=0>",
758                 $gif, $sz->[0], $sz->[1], $ll eq " " ? "&nbsp;" : $l;
759             }
760         }
761 }
762
763 sub tab_start {
764     print qq~    <td nowrap>
765       <table border="0" cellspacing="0" cellpadding="0">
766         <tr>
767           <td background="/images/tabs/bg.jpg"><img src="/images/tabs/left.jpg" width="12" height="21" nowrap></td>
768           <td background="/images/tabs/bg.jpg" nowrap>
769           ~;
770 }
771
772
773 sub tab_end {
774      print qq~</td>
775           <td background="/images/tabs/bg.jpg" nowrap><img src="/images/tabs/right.jpg" width="15" height="21"></td>
776         </tr>
777         <tr>
778           <td nowrap><img src="/images/tabs/right_bottom.jpg" width="12" height="4"></td>
779           <td background="/images/tabs/bottom.jpg" nowrap><img src="/images/tabs/bottom.jpg" width="17" height="4"></td>
780           <td nowrap><img src="/images/tabs/left_bottom.jpg" width="15" height="4"></td>        </tr>
781       </table>
782
783     </td>~;
784 }
785
786 sub create_menu {
787    my $tmpid;
788    if ($c eq "") { $tmpid = "other"; }
789    else { $tmpid = $c; }
790
791    my $tmpimg;
792    if ($c eq "") { $tmpimg = "other"; }
793    if ($inlist eq "true" && $c ne "") { $tmpimg = "$c"; }
794    if ($inlist ne "true" && $c ne "") { $tmpimg = "unknown"; }
795
796    if ($in{'cat'} eq $c) {
797       print qq~
798          <div id="$tmpid\_menu" class="menucontainer" style="display:none" align="left">
799          <div id="$tmpid\_menu" class="title_menu"><center>$t</center></a></div>
800       ~;
801    } else {
802       print qq~
803          <div id="$tmpid\_menu" class="menucontainer" style="display:none" align="left" onMouseOver="mouseover('$tmpid\_image','/images/cats/$tmpimg\_over.jpg');" onMouseOut="mouseout('$tmpid\_image','/images/cats/$tmpimg.jpg');">
804          <div id="$tmpid\_menu" class="title_menu"><center>$t</center></a></div>
805       ~;
806    }
807
808    foreach $m (@msc_modules) {
809       next if ($m->{'category'} ne $c);
810       print "<div id=\"$tmpid\_menu\" class=\"menu\">";
811       print "<a href=/$m->{'dir'}/>";
812       print "<div id=\"$tmpid\_menu\">";
813       print "<img src=\"/$m->{'dir'}/images/icon.gif\" width=\"20\" height=\"20\" border=\"0\"> $m->{'desc'}";
814       print "</div></a></div>";
815    }
816
817    print "</div>";
818 }
819
820 1;
821