This fixes Bug #0000652 - IE8 needs forced blank, other browser are still fine
[ipfire-2.x.git] / html / html / themes / ipfire / include / functions.pl
CommitLineData
f8e080ef 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
f8e080ef
MT
21
22sub showmenu() {
23 print <<EOF
94ec137d
CS
24 <div id="menu">
25 <ul>
f8e080ef
MT
26EOF
27;
28 foreach my $k1 ( sort keys %$menu ) {
94ec137d
CS
29 if (! $menu->{$k1}{'enabled'}) {
30 next;
31 }
32 my $link = getlink($menu->{$k1});
33 if ($link eq '') {
34 next;
35 }
36 if (! is_menu_visible($link)) {
37 next;
38 }
39 if ($menu->{$k1}->{'selected'}) {
40 print "<li><a href=\"$link\" class=\"active\">$menu->{$k1}{'caption'}</a></li>";
41 } else {
42 print "<li><a href=\"$link\">$menu->{$k1}{'caption'}</a></li>";
43 }
f8e080ef
MT
44 }
45 print <<EOF
94ec137d
CS
46 </ul>
47 </div>
f8e080ef
MT
48EOF
49;
50}
51
52sub getselected($) {
53 my $root = shift;
54 if (!$root) {
94ec137d 55 return 0;
f8e080ef
MT
56 }
57
58 foreach my $item (%$root) {
94ec137d
CS
59 if ($root->{$item}{'selected'}) {
60 return $root->{$item};
61 }
f8e080ef
MT
62 }
63}
64
65sub showsubsection($$) {
66 my $root = shift;
67
68 if (! $root) {
94ec137d 69 return;
f8e080ef
MT
70 }
71 my $selected = getselected($root);
72 if (! $selected) {
94ec137d 73 return;
f8e080ef
MT
74 }
75 my $submenus = $selected->{'subMenu'};
76 if (! $submenus) {
94ec137d 77 return;
f8e080ef
MT
78 }
79
80 print <<EOF
94ec137d
CS
81 <h4><span>Side</span>menu</h4>
82 <ul class="links">
f8e080ef
MT
83EOF
84;
85 foreach my $item (sort keys %$submenus) {
94ec137d
CS
86 my $hash = $submenus->{$item};
87 if (! $hash->{'enabled'}) {
88 next;
89 }
90 my $link = getlink($hash);
91 if ($link eq '') {
92 next;
93 }
94 if (! is_menu_visible($link)) {
95 next;
96 }
97 if ($hash->{'selected'}) {
98 print '<li class="selected">';
99 } else {
100 print '<li>';
101 }
102
103 print "<a href=\"$link\">$hash->{'caption'}</a></li>";
f8e080ef
MT
104 }
105
106 print <<EOF
94ec137d 107 </ul>
f8e080ef
MT
108EOF
109;
110}
111
112
113sub showsubsubsection($) {
114 my $root = shift;
115 if (!$root) {
94ec137d 116 return;
f8e080ef
MT
117 }
118 my $selected = getselected($root);
119 if (! $selected) {
94ec137d 120 return
f8e080ef
MT
121 }
122 if (! $selected->{'subMenu'}) {
94ec137d 123 return
f8e080ef
MT
124 }
125
126 showsubsection($selected->{'subMenu'}, 'menu-subtop');
127}
128
129sub openpage {
130 my $title = shift;
131 my $boh = shift;
132 my $extrahead = shift;
133
134 @URI=split ('\?', $ENV{'REQUEST_URI'} );
6be4dd24 135 &General::readhash("${swroot}/main/settings", \%settings);
f8e080ef
MT
136 &genmenu();
137
138 my $h2 = gettitle($menu);
139
140 $title = "IPFire - $title";
141 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
142 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
143 }
144
145 print <<END
146<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
147
148<html>
149 <head>
150 <title>$title</title>
151
152 $extrahead
153 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
154END
155;
156 if ($settings{'FX'} ne 'off') {
157 print <<END
158 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
159 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
160END
161;
162 }
163 print <<END
164 <link rel="shortcut icon" href="/favicon.ico" />
165 <link rel="stylesheet" type="text/css" href="/themes/ipfire/include/style.css" />
166 <script language="javascript" type="text/javascript">
167
168 function swapVisibility(id) {
169 el = document.getElementById(id);
94ec137d
CS
170 if(el.style.display != 'block') {
171 el.style.display = 'block'
172 }
173 else {
174 el.style.display = 'none'
175 }
f8e080ef
MT
176 }
177 </script>
18322edf
CS
178END
179;
180if ($settings{'SPEED'} ne 'off') {
181print <<END
d6a60bb3
DG
182 <script type="text/javascript" src="/include/jquery-1.2.6.min.js"></script>
183 <script type="text/javascript">
184 var t_current;
185 var t_last;
186 var rxb_current;
187 var rxb_last;
188 var txb_current;
189 var txb_last;
190 function refreshInetInfo() {
191 \$.ajax({
192 url: '/cgi-bin/speed.cgi',
193 success: function(xml){
194 t_current = new Date();
195 var t_diff = t_current - t_last;
196 t_last = t_current;
197
198 rxb_current = \$("rxb",xml).text();
199 var rxb_diff = rxb_current - rxb_last;
200 rxb_last = rxb_current;
201
202 var rx_kbs = rxb_diff/t_diff;
203 rx_kbs = Math.round(rx_kbs*10)/10;
204
205 txb_current = \$("txb",xml).text();
206 var txb_diff = txb_current - txb_last;
207 txb_last = txb_current;
208
209 var tx_kbs = txb_diff/t_diff;
210 tx_kbs = Math.round(tx_kbs*10)/10;
211
212 \$("#rx_kbs").text(rx_kbs + ' kb/s');
213 \$("#tx_kbs").text(tx_kbs + ' kb/s');
94ec137d 214 }
d6a60bb3
DG
215 });
216 window.setTimeout("refreshInetInfo()", 3000);
217 }
218 \$(document).ready(function(){
219 refreshInetInfo();
220 });
221 </script>
f8e080ef 222 </head>
d6a60bb3 223 <body>
18322edf
CS
224END
225;
226}
227else {
228print "</head><body>";}
229print <<END
f8e080ef
MT
230<!-- IPFIRE HEADER -->
231
232<div id="header">
233
94ec137d 234 <div id="header_inner" class="fixed">
f8e080ef 235
94ec137d 236 <div id="logo">
d86ddb48
MT
237END
238;
239 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
240 print "<h1><span>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</span></h1><br />";
241 } else {
94ec137d
CS
242 print "<h1><span>IPFire</span></h1><br />";
243 }
244 print <<END
245 <h2>$h2</h2>
246 </div>
f8e080ef
MT
247
248END
249;
94ec137d 250 &showmenu();
f8e080ef 251
94ec137d
CS
252print <<END
253 </div>
f8e080ef
MT
254</div>
255
256<div id="main">
94ec137d
CS
257 <div id="main_inner" class="fixed">
258 <div id="primaryContent_2columns">
259 <div id="columnA_2columns">
f8e080ef
MT
260END
261;
262}
263
264sub openpagewithoutmenu {
265 my $title = shift;
266 my $boh = shift;
267 my $extrahead = shift;
268
269 @URI=split ('\?', $ENV{'REQUEST_URI'} );
6be4dd24 270 &General::readhash("${swroot}/main/settings", \%settings);
f8e080ef
MT
271 &genmenu();
272
273 my $h2 = gettitle($menu);
274
275 $title = "IPFire - $title";
276 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
277 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
278 }
279
280 print <<END
281<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
282
283<html>
284 <head>
285 <title>$title</title>
286
287 $extrahead
288 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
289END
290;
291 if ($settings{'FX'} ne 'off') {
292 print <<END
293 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
294 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
295END
296;
297 }
298 print <<END
299 <link rel="shortcut icon" href="/favicon.ico" />
300 <link rel="stylesheet" type="text/css" href="/include/style.css" />
301 <script language="javascript" type="text/javascript">
302
303 function swapVisibility(id) {
304 el = document.getElementById(id);
94ec137d
CS
305 if(el.style.display != 'block') {
306 el.style.display = 'block'
307 }
308 else {
309 el.style.display = 'none'
310 }
f8e080ef
MT
311 }
312 </script>
313
314 </head>
315 <body>
316<!-- IPFIRE HEADER -->
317
318<div id="header">
319
94ec137d 320 <div id="header_inner" class="fixed">
f8e080ef 321
94ec137d
CS
322 <div id="logo">
323 <h1><span>IPFire</span></h1>
324 <h2>$h2</h2>
325 </div>
326 </div>
f8e080ef
MT
327</div>
328
329<div id="main">
94ec137d
CS
330 <div id="main_inner" class="fixed">
331 <div id="primaryContent_2columns">
332 <div id="columnA_2columns">
f8e080ef
MT
333END
334;
335}
336
337sub closepage () {
338 my $status = &connectionstatus();
339 $uptime = `/usr/bin/uptime`;
94ec137d 340
f8e080ef 341 print <<END
94ec137d
CS
342 </div>
343 </div>
f8e080ef 344
94ec137d
CS
345 <div id="secondaryContent_2columns">
346
347 <div id="columnC_2columns">
f8e080ef
MT
348END
349;
350 &showsubsection($menu);
351 &showsubsubsection($menu);
352
94ec137d
CS
353 print <<END
354 </div>
355 </div>
356
357 <br class="clear" />
358 <div id="footer" class="fixed">
ad35f3d2 359 <b>Status:</b> $status <b>Uptime:</b>$uptime
18322edf
CS
360END
361;
362if ($settings{'SPEED'} ne 'off') {
363print <<END
94ec137d 364 <br />
d6a60bb3 365 <b>$Lang::tr{'bandwidth usage'}:</b>
8a5823b8
JPT
366 $Lang::tr{'incoming'}: <span id="rx_kbs"></span>&nbsp;$Lang::tr{'outgoing'}: <span id="tx_kbs"></span>
367
18322edf
CS
368END
369;
370}
371print <<END
94ec137d
CS
372 </div>
373 </div>
e455cafe
MT
374</div>
375</body>
f8e080ef
MT
376</html>
377END
378;
379}
380
381sub openbigbox
382{
383}
384
385sub closebigbox
386{
387}
388
389sub openbox
390{
94ec137d
CS
391 $width = $_[0];
392 $align = $_[1];
393 $caption = $_[2];
f8e080ef 394
94ec137d 395 print <<END
f8e080ef 396<!-- openbox -->
94ec137d 397 <div class="post" align="$align">
f8e080ef
MT
398END
399;
400
94ec137d 401 if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
f8e080ef
MT
402}
403
404sub closebox
405{
94ec137d
CS
406 print <<END
407 </div>
408 <br class="clear" />
409 <!-- closebox -->
f8e080ef
MT
410END
411;
412}
413
4141;