Mal richtig schnell ein kleines Python-Script geschrieben, welches die Paket-Datenban...
[people/pmueller/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>
94ec137d
CS
159 <script type="text/javascript" language="javascript">
160
161 var http_request = false;
162
163 function LoadInetInfo(url) {
164
165 http_request = false;
166
167 if (window.XMLHttpRequest) { // Mozilla, Safari,...
168 http_request = new XMLHttpRequest();
169 if (http_request.overrideMimeType) {
170 http_request.overrideMimeType('text/xml');
171 // zu dieser Zeile siehe weiter unten
172 }
173 } else if (window.ActiveXObject) { // IE
174 try {
175 http_request = new ActiveXObject("Msxml2.XMLHTTP");
176 } catch (e) {
177 try {
178 http_request = new ActiveXObject("Microsoft.XMLHTTP");
179 } catch (e) {}
180 }
181 }
182
183 if (!http_request) {
184 alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
185 return false;
186 }
187 http_request.onreadystatechange = DisplayInetInfo;
188 http_request.open('GET', url, true);
189 http_request.send(null);
190
191 }
192
193 function DisplayInetInfo() {
194 if (http_request.readyState == 4) {
195 var xmldoc = http_request.responseXML;
196 var root1_node = xmldoc.getElementsByTagName('rx_kbs').item(0);
197 var root2_node = xmldoc.getElementsByTagName('tx_kbs').item(0);
198 var root3_node = xmldoc.getElementsByTagName('rxb').item(0);
199 var root4_node = xmldoc.getElementsByTagName('txb').item(0);
200
201 document.forms['speed'].txkb.value = root1_node.firstChild.data;
202 document.forms['speed'].rxkb.value = root2_node.firstChild.data;
203
204 // document.getElementsByTagName("input")[0].style.color = "#00FF00";
205 url = "/cgi-bin/speed.cgi?rxb_last=" + root3_node.firstChild.data + "&txb_last=" + root4_node.firstChild.data;
206
207 window.setTimeout("LoadInetInfo(url)", 3000);
208 }
209
210 }
211 </script>
f8e080ef 212 </head>
4aedc962 213 <body onLoad="LoadInetInfo('/cgi-bin/speed.cgi')">
f8e080ef
MT
214<!-- IPFIRE HEADER -->
215
216<div id="header">
217
94ec137d 218 <div id="header_inner" class="fixed">
f8e080ef 219
94ec137d 220 <div id="logo">
d86ddb48
MT
221END
222;
223 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
224 print "<h1><span>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</span></h1><br />";
225 } else {
94ec137d
CS
226 print "<h1><span>IPFire</span></h1><br />";
227 }
228 print <<END
229 <h2>$h2</h2>
230 </div>
f8e080ef
MT
231
232END
233;
94ec137d 234 &showmenu();
f8e080ef 235
94ec137d
CS
236print <<END
237 </div>
f8e080ef
MT
238</div>
239
240<div id="main">
94ec137d
CS
241 <div id="main_inner" class="fixed">
242 <div id="primaryContent_2columns">
243 <div id="columnA_2columns">
f8e080ef
MT
244END
245;
246}
247
248sub openpagewithoutmenu {
249 my $title = shift;
250 my $boh = shift;
251 my $extrahead = shift;
252
253 @URI=split ('\?', $ENV{'REQUEST_URI'} );
6be4dd24 254 &General::readhash("${swroot}/main/settings", \%settings);
f8e080ef
MT
255 &genmenu();
256
257 my $h2 = gettitle($menu);
258
259 $title = "IPFire - $title";
260 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
261 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
262 }
263
264 print <<END
265<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
266
267<html>
268 <head>
269 <title>$title</title>
270
271 $extrahead
272 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
273END
274;
275 if ($settings{'FX'} ne 'off') {
276 print <<END
277 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
278 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
279END
280;
281 }
282 print <<END
283 <link rel="shortcut icon" href="/favicon.ico" />
284 <link rel="stylesheet" type="text/css" href="/include/style.css" />
285 <script language="javascript" type="text/javascript">
286
287 function swapVisibility(id) {
288 el = document.getElementById(id);
94ec137d
CS
289 if(el.style.display != 'block') {
290 el.style.display = 'block'
291 }
292 else {
293 el.style.display = 'none'
294 }
f8e080ef
MT
295 }
296 </script>
297
298 </head>
299 <body>
300<!-- IPFIRE HEADER -->
301
302<div id="header">
303
94ec137d 304 <div id="header_inner" class="fixed">
f8e080ef 305
94ec137d
CS
306 <div id="logo">
307 <h1><span>IPFire</span></h1>
308 <h2>$h2</h2>
309 </div>
310 </div>
f8e080ef
MT
311</div>
312
313<div id="main">
94ec137d
CS
314 <div id="main_inner" class="fixed">
315 <div id="primaryContent_2columns">
316 <div id="columnA_2columns">
f8e080ef
MT
317END
318;
319}
320
321sub closepage () {
322 my $status = &connectionstatus();
323 $uptime = `/usr/bin/uptime`;
94ec137d 324
f8e080ef 325 print <<END
94ec137d
CS
326 </div>
327 </div>
f8e080ef 328
94ec137d
CS
329 <div id="secondaryContent_2columns">
330
331 <div id="columnC_2columns">
f8e080ef
MT
332END
333;
334 &showsubsection($menu);
335 &showsubsubsection($menu);
336
94ec137d
CS
337 print <<END
338 </div>
339 </div>
340
341 <br class="clear" />
342 <div id="footer" class="fixed">
343 <b>Status:</b> $status <b>Uptime:</b>$uptime <b>Version:</b> $FIREBUILD
344 <br />
345 <form name='speed'>
346 <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: 1px solid #FFFFFF; padding: 0; background-color: #FFFFFF; vertical-align: middle" />
347 $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: 1px solid #FFFFFF; padding: 0; background-color: #FFFFFF; vertical-align: middle"/>
348 </form>
349 </div>
350 </div>
e455cafe
MT
351</div>
352</body>
f8e080ef
MT
353</html>
354END
355;
356}
357
358sub openbigbox
359{
360}
361
362sub closebigbox
363{
364}
365
366sub openbox
367{
94ec137d
CS
368 $width = $_[0];
369 $align = $_[1];
370 $caption = $_[2];
f8e080ef 371
94ec137d 372 print <<END
f8e080ef 373<!-- openbox -->
94ec137d 374 <div class="post" align="$align">
f8e080ef
MT
375END
376;
377
94ec137d 378 if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
f8e080ef
MT
379}
380
381sub closebox
382{
94ec137d
CS
383 print <<END
384 </div>
385 <br class="clear" />
386 <!-- closebox -->
f8e080ef
MT
387END
388;
389}
390
3911;