]> git.ipfire.org Git - ipfire-2.x.git/blame - html/html/themes/ipfire/include/functions.pl
Pakfire laedt die Listen jetzt besser und hat eine veraenderte Oberflaeche bekommen.
[ipfire-2.x.git] / html / html / themes / ipfire / include / functions.pl
CommitLineData
f8e080ef
MT
1#!/usr/bin/perl
2
3sub showmenu() {
4 print <<EOF
94ec137d
CS
5 <div id="menu">
6 <ul>
f8e080ef
MT
7EOF
8;
9 foreach my $k1 ( sort keys %$menu ) {
94ec137d
CS
10 if (! $menu->{$k1}{'enabled'}) {
11 next;
12 }
13 my $link = getlink($menu->{$k1});
14 if ($link eq '') {
15 next;
16 }
17 if (! is_menu_visible($link)) {
18 next;
19 }
20 if ($menu->{$k1}->{'selected'}) {
21 print "<li><a href=\"$link\" class=\"active\">$menu->{$k1}{'caption'}</a></li>";
22 } else {
23 print "<li><a href=\"$link\">$menu->{$k1}{'caption'}</a></li>";
24 }
f8e080ef
MT
25 }
26 print <<EOF
94ec137d
CS
27 </ul>
28 </div>
f8e080ef
MT
29EOF
30;
31}
32
33sub getselected($) {
34 my $root = shift;
35 if (!$root) {
94ec137d 36 return 0;
f8e080ef
MT
37 }
38
39 foreach my $item (%$root) {
94ec137d
CS
40 if ($root->{$item}{'selected'}) {
41 return $root->{$item};
42 }
f8e080ef
MT
43 }
44}
45
46sub showsubsection($$) {
47 my $root = shift;
48
49 if (! $root) {
94ec137d 50 return;
f8e080ef
MT
51 }
52 my $selected = getselected($root);
53 if (! $selected) {
94ec137d 54 return;
f8e080ef
MT
55 }
56 my $submenus = $selected->{'subMenu'};
57 if (! $submenus) {
94ec137d 58 return;
f8e080ef
MT
59 }
60
61 print <<EOF
94ec137d
CS
62 <h4><span>Side</span>menu</h4>
63 <ul class="links">
f8e080ef
MT
64EOF
65;
66 foreach my $item (sort keys %$submenus) {
94ec137d
CS
67 my $hash = $submenus->{$item};
68 if (! $hash->{'enabled'}) {
69 next;
70 }
71 my $link = getlink($hash);
72 if ($link eq '') {
73 next;
74 }
75 if (! is_menu_visible($link)) {
76 next;
77 }
78 if ($hash->{'selected'}) {
79 print '<li class="selected">';
80 } else {
81 print '<li>';
82 }
83
84 print "<a href=\"$link\">$hash->{'caption'}</a></li>";
f8e080ef
MT
85 }
86
87 print <<EOF
94ec137d 88 </ul>
f8e080ef
MT
89EOF
90;
91}
92
93
94sub showsubsubsection($) {
95 my $root = shift;
96 if (!$root) {
94ec137d 97 return;
f8e080ef
MT
98 }
99 my $selected = getselected($root);
100 if (! $selected) {
94ec137d 101 return
f8e080ef
MT
102 }
103 if (! $selected->{'subMenu'}) {
94ec137d 104 return
f8e080ef
MT
105 }
106
107 showsubsection($selected->{'subMenu'}, 'menu-subtop');
108}
109
110sub openpage {
111 my $title = shift;
112 my $boh = shift;
113 my $extrahead = shift;
114
115 @URI=split ('\?', $ENV{'REQUEST_URI'} );
6be4dd24 116 &General::readhash("${swroot}/main/settings", \%settings);
f8e080ef
MT
117 &genmenu();
118
119 my $h2 = gettitle($menu);
120
121 $title = "IPFire - $title";
122 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
123 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
124 }
125
126 print <<END
127<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
128
129<html>
130 <head>
131 <title>$title</title>
132
133 $extrahead
134 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
135END
136;
137 if ($settings{'FX'} ne 'off') {
138 print <<END
139 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
140 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
141END
142;
143 }
144 print <<END
145 <link rel="shortcut icon" href="/favicon.ico" />
146 <link rel="stylesheet" type="text/css" href="/themes/ipfire/include/style.css" />
147 <script language="javascript" type="text/javascript">
148
149 function swapVisibility(id) {
150 el = document.getElementById(id);
94ec137d
CS
151 if(el.style.display != 'block') {
152 el.style.display = 'block'
153 }
154 else {
155 el.style.display = 'none'
156 }
f8e080ef
MT
157 }
158 </script>
18322edf
CS
159END
160;
161if ($settings{'SPEED'} ne 'off') {
162print <<END
94ec137d
CS
163 <script type="text/javascript" language="javascript">
164
165 var http_request = false;
166
167 function LoadInetInfo(url) {
168
169 http_request = false;
170
171 if (window.XMLHttpRequest) { // Mozilla, Safari,...
172 http_request = new XMLHttpRequest();
173 if (http_request.overrideMimeType) {
174 http_request.overrideMimeType('text/xml');
175 // zu dieser Zeile siehe weiter unten
176 }
177 } else if (window.ActiveXObject) { // IE
178 try {
179 http_request = new ActiveXObject("Msxml2.XMLHTTP");
180 } catch (e) {
181 try {
182 http_request = new ActiveXObject("Microsoft.XMLHTTP");
183 } catch (e) {}
184 }
185 }
186
187 if (!http_request) {
188 alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
189 return false;
190 }
191 http_request.onreadystatechange = DisplayInetInfo;
192 http_request.open('GET', url, true);
193 http_request.send(null);
194
195 }
196
197 function DisplayInetInfo() {
198 if (http_request.readyState == 4) {
199 var xmldoc = http_request.responseXML;
200 var root1_node = xmldoc.getElementsByTagName('rx_kbs').item(0);
201 var root2_node = xmldoc.getElementsByTagName('tx_kbs').item(0);
202 var root3_node = xmldoc.getElementsByTagName('rxb').item(0);
203 var root4_node = xmldoc.getElementsByTagName('txb').item(0);
204
205 document.forms['speed'].txkb.value = root1_node.firstChild.data;
206 document.forms['speed'].rxkb.value = root2_node.firstChild.data;
207
208 // document.getElementsByTagName("input")[0].style.color = "#00FF00";
209 url = "/cgi-bin/speed.cgi?rxb_last=" + root3_node.firstChild.data + "&txb_last=" + root4_node.firstChild.data;
210
211 window.setTimeout("LoadInetInfo(url)", 3000);
212 }
213
214 }
215 </script>
f8e080ef 216 </head>
4aedc962 217 <body onLoad="LoadInetInfo('/cgi-bin/speed.cgi')">
18322edf
CS
218END
219;
220}
221else {
222print "</head><body>";}
223print <<END
f8e080ef
MT
224<!-- IPFIRE HEADER -->
225
226<div id="header">
227
94ec137d 228 <div id="header_inner" class="fixed">
f8e080ef 229
94ec137d 230 <div id="logo">
d86ddb48
MT
231END
232;
233 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
234 print "<h1><span>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</span></h1><br />";
235 } else {
94ec137d
CS
236 print "<h1><span>IPFire</span></h1><br />";
237 }
238 print <<END
239 <h2>$h2</h2>
240 </div>
f8e080ef
MT
241
242END
243;
94ec137d 244 &showmenu();
f8e080ef 245
94ec137d
CS
246print <<END
247 </div>
f8e080ef
MT
248</div>
249
250<div id="main">
94ec137d
CS
251 <div id="main_inner" class="fixed">
252 <div id="primaryContent_2columns">
253 <div id="columnA_2columns">
f8e080ef
MT
254END
255;
256}
257
258sub openpagewithoutmenu {
259 my $title = shift;
260 my $boh = shift;
261 my $extrahead = shift;
262
263 @URI=split ('\?', $ENV{'REQUEST_URI'} );
6be4dd24 264 &General::readhash("${swroot}/main/settings", \%settings);
f8e080ef
MT
265 &genmenu();
266
267 my $h2 = gettitle($menu);
268
269 $title = "IPFire - $title";
270 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
271 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
272 }
273
274 print <<END
275<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
276
277<html>
278 <head>
279 <title>$title</title>
280
281 $extrahead
282 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
283END
284;
285 if ($settings{'FX'} ne 'off') {
286 print <<END
287 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
288 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
289END
290;
291 }
292 print <<END
293 <link rel="shortcut icon" href="/favicon.ico" />
294 <link rel="stylesheet" type="text/css" href="/include/style.css" />
295 <script language="javascript" type="text/javascript">
296
297 function swapVisibility(id) {
298 el = document.getElementById(id);
94ec137d
CS
299 if(el.style.display != 'block') {
300 el.style.display = 'block'
301 }
302 else {
303 el.style.display = 'none'
304 }
f8e080ef
MT
305 }
306 </script>
307
308 </head>
309 <body>
310<!-- IPFIRE HEADER -->
311
312<div id="header">
313
94ec137d 314 <div id="header_inner" class="fixed">
f8e080ef 315
94ec137d
CS
316 <div id="logo">
317 <h1><span>IPFire</span></h1>
318 <h2>$h2</h2>
319 </div>
320 </div>
f8e080ef
MT
321</div>
322
323<div id="main">
94ec137d
CS
324 <div id="main_inner" class="fixed">
325 <div id="primaryContent_2columns">
326 <div id="columnA_2columns">
f8e080ef
MT
327END
328;
329}
330
331sub closepage () {
332 my $status = &connectionstatus();
333 $uptime = `/usr/bin/uptime`;
94ec137d 334
f8e080ef 335 print <<END
94ec137d
CS
336 </div>
337 </div>
f8e080ef 338
94ec137d
CS
339 <div id="secondaryContent_2columns">
340
341 <div id="columnC_2columns">
f8e080ef
MT
342END
343;
344 &showsubsection($menu);
345 &showsubsubsection($menu);
346
94ec137d
CS
347 print <<END
348 </div>
349 </div>
350
351 <br class="clear" />
352 <div id="footer" class="fixed">
353 <b>Status:</b> $status <b>Uptime:</b>$uptime <b>Version:</b> $FIREBUILD
18322edf
CS
354END
355;
356if ($settings{'SPEED'} ne 'off') {
357print <<END
94ec137d
CS
358 <br />
359 <form name='speed'>
7c98b475
CS
360 <b>$Lang::tr{'bandwidth usage'}:</b> $Lang::tr{'incoming'}:<input type="text" name="rxkb" size="5" value="0 kb/s" style="font-size: 12px; font-family: Arial, Helvetica;text-align: center;color:green; border: none; padding: 0; background-color: #FFFFFF;vertical-align: middle" />
361 $Lang::tr{'outgoing'}: <input type="text" name="txkb" size="5" value="0 kb/s" style="font-size: 12px; font-family: Arial, Helvetica;text-align: center;color:red; border: none; padding: 0; background-color: #FFFFFF;vertical-align: middle"/>
94ec137d 362 </form>
18322edf
CS
363END
364;
365}
366print <<END
94ec137d
CS
367 </div>
368 </div>
e455cafe
MT
369</div>
370</body>
f8e080ef
MT
371</html>
372END
373;
374}
375
376sub openbigbox
377{
378}
379
380sub closebigbox
381{
382}
383
384sub openbox
385{
94ec137d
CS
386 $width = $_[0];
387 $align = $_[1];
388 $caption = $_[2];
f8e080ef 389
94ec137d 390 print <<END
f8e080ef 391<!-- openbox -->
94ec137d 392 <div class="post" align="$align">
f8e080ef
MT
393END
394;
395
94ec137d 396 if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
f8e080ef
MT
397}
398
399sub closebox
400{
94ec137d
CS
401 print <<END
402 </div>
403 <br class="clear" />
404 <!-- closebox -->
f8e080ef
MT
405END
406;
407}
408
4091;