]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
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 | ############################################################################### | |
21 | ||
22 | sub showmenu() { | |
23 | print <<EOF | |
24 | <div id="menu"> | |
25 | <ul> | |
26 | EOF | |
27 | ; | |
28 | foreach my $k1 ( sort keys %$menu ) { | |
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 | } | |
44 | } | |
45 | print <<EOF | |
46 | </ul> | |
47 | </div> | |
48 | EOF | |
49 | ; | |
50 | } | |
51 | ||
52 | sub getselected($) { | |
53 | my $root = shift; | |
54 | if (!$root) { | |
55 | return 0; | |
56 | } | |
57 | ||
58 | foreach my $item (%$root) { | |
59 | if ($root->{$item}{'selected'}) { | |
60 | return $root->{$item}; | |
61 | } | |
62 | } | |
63 | } | |
64 | ||
65 | sub showsubsection($$) { | |
66 | my $root = shift; | |
67 | ||
68 | if (! $root) { | |
69 | return; | |
70 | } | |
71 | my $selected = getselected($root); | |
72 | if (! $selected) { | |
73 | return; | |
74 | } | |
75 | my $submenus = $selected->{'subMenu'}; | |
76 | if (! $submenus) { | |
77 | return; | |
78 | } | |
79 | ||
80 | print <<EOF | |
81 | <h4><span>Side</span>menu</h4> | |
82 | <ul class="links"> | |
83 | EOF | |
84 | ; | |
85 | foreach my $item (sort keys %$submenus) { | |
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>"; | |
104 | } | |
105 | ||
106 | print <<EOF | |
107 | </ul> | |
108 | EOF | |
109 | ; | |
110 | } | |
111 | ||
112 | ||
113 | sub showsubsubsection($) { | |
114 | my $root = shift; | |
115 | if (!$root) { | |
116 | return; | |
117 | } | |
118 | my $selected = getselected($root); | |
119 | if (! $selected) { | |
120 | return | |
121 | } | |
122 | if (! $selected->{'subMenu'}) { | |
123 | return | |
124 | } | |
125 | ||
126 | showsubsection($selected->{'subMenu'}, 'menu-subtop'); | |
127 | } | |
128 | ||
129 | sub openpage { | |
130 | my $title = shift; | |
131 | my $boh = shift; | |
132 | my $extrahead = shift; | |
133 | ||
134 | @URI=split ('\?', $ENV{'REQUEST_URI'} ); | |
135 | &General::readhash("${swroot}/main/settings", \%settings); | |
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"/> | |
154 | END | |
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)" /> | |
160 | END | |
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); | |
170 | if(el.style.display != 'block') { | |
171 | el.style.display = 'block' | |
172 | } | |
173 | else { | |
174 | el.style.display = 'none' | |
175 | } | |
176 | } | |
177 | </script> | |
178 | END | |
179 | ; | |
180 | if ($settings{'SPEED'} ne 'off') { | |
181 | print <<END | |
182 | <script type="text/javascript" language="javascript"> | |
183 | ||
184 | var http_request = false; | |
185 | ||
186 | function LoadInetInfo(url) { | |
187 | ||
188 | http_request = false; | |
189 | ||
190 | if (window.XMLHttpRequest) { // Mozilla, Safari,... | |
191 | http_request = new XMLHttpRequest(); | |
192 | if (http_request.overrideMimeType) { | |
193 | http_request.overrideMimeType('text/xml'); | |
194 | // zu dieser Zeile siehe weiter unten | |
195 | } | |
196 | } else if (window.ActiveXObject) { // IE | |
197 | try { | |
198 | http_request = new ActiveXObject("Msxml2.XMLHTTP"); | |
199 | } catch (e) { | |
200 | try { | |
201 | http_request = new ActiveXObject("Microsoft.XMLHTTP"); | |
202 | } catch (e) {} | |
203 | } | |
204 | } | |
205 | ||
206 | if (!http_request) { | |
207 | alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); | |
208 | return false; | |
209 | } | |
210 | http_request.onreadystatechange = DisplayInetInfo; | |
211 | http_request.open('GET', url, true); | |
212 | http_request.send(null); | |
213 | ||
214 | } | |
215 | ||
216 | function DisplayInetInfo() { | |
217 | if (http_request.readyState == 4) { | |
218 | var xmldoc = http_request.responseXML; | |
219 | var root1_node = xmldoc.getElementsByTagName('rx_kbs').item(0); | |
220 | var root2_node = xmldoc.getElementsByTagName('tx_kbs').item(0); | |
221 | var root3_node = xmldoc.getElementsByTagName('rxb').item(0); | |
222 | var root4_node = xmldoc.getElementsByTagName('txb').item(0); | |
223 | ||
224 | document.forms['speed'].txkb.value = root1_node.firstChild.data; | |
225 | document.forms['speed'].rxkb.value = root2_node.firstChild.data; | |
226 | ||
227 | // document.getElementsByTagName("input")[0].style.color = "#00FF00"; | |
228 | url = "/cgi-bin/speed.cgi?rxb_last=" + root3_node.firstChild.data + "&txb_last=" + root4_node.firstChild.data; | |
229 | ||
230 | window.setTimeout("LoadInetInfo(url)", 3000); | |
231 | } | |
232 | ||
233 | } | |
234 | </script> | |
235 | </head> | |
236 | <body onLoad="LoadInetInfo('/cgi-bin/speed.cgi')"> | |
237 | END | |
238 | ; | |
239 | } | |
240 | else { | |
241 | print "</head><body>";} | |
242 | print <<END | |
243 | <!-- IPFIRE HEADER --> | |
244 | ||
245 | <div id="header"> | |
246 | ||
247 | <div id="header_inner" class="fixed"> | |
248 | ||
249 | <div id="logo"> | |
250 | END | |
251 | ; | |
252 | if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') { | |
253 | print "<h1><span>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</span></h1><br />"; | |
254 | } else { | |
255 | print "<h1><span>IPFire</span></h1><br />"; | |
256 | } | |
257 | print <<END | |
258 | <h2>$h2</h2> | |
259 | </div> | |
260 | ||
261 | END | |
262 | ; | |
263 | &showmenu(); | |
264 | ||
265 | print <<END | |
266 | </div> | |
267 | </div> | |
268 | ||
269 | <div id="main"> | |
270 | <div id="main_inner" class="fixed"> | |
271 | <div id="primaryContent_2columns"> | |
272 | <div id="columnA_2columns"> | |
273 | END | |
274 | ; | |
275 | } | |
276 | ||
277 | sub openpagewithoutmenu { | |
278 | my $title = shift; | |
279 | my $boh = shift; | |
280 | my $extrahead = shift; | |
281 | ||
282 | @URI=split ('\?', $ENV{'REQUEST_URI'} ); | |
283 | &General::readhash("${swroot}/main/settings", \%settings); | |
284 | &genmenu(); | |
285 | ||
286 | my $h2 = gettitle($menu); | |
287 | ||
288 | $title = "IPFire - $title"; | |
289 | if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') { | |
290 | $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title"; | |
291 | } | |
292 | ||
293 | print <<END | |
294 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
295 | ||
296 | <html> | |
297 | <head> | |
298 | <title>$title</title> | |
299 | ||
300 | $extrahead | |
301 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | |
302 | END | |
303 | ; | |
304 | if ($settings{'FX'} ne 'off') { | |
305 | print <<END | |
306 | <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" /> | |
307 | <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" /> | |
308 | END | |
309 | ; | |
310 | } | |
311 | print <<END | |
312 | <link rel="shortcut icon" href="/favicon.ico" /> | |
313 | <link rel="stylesheet" type="text/css" href="/include/style.css" /> | |
314 | <script language="javascript" type="text/javascript"> | |
315 | ||
316 | function swapVisibility(id) { | |
317 | el = document.getElementById(id); | |
318 | if(el.style.display != 'block') { | |
319 | el.style.display = 'block' | |
320 | } | |
321 | else { | |
322 | el.style.display = 'none' | |
323 | } | |
324 | } | |
325 | </script> | |
326 | ||
327 | </head> | |
328 | <body> | |
329 | <!-- IPFIRE HEADER --> | |
330 | ||
331 | <div id="header"> | |
332 | ||
333 | <div id="header_inner" class="fixed"> | |
334 | ||
335 | <div id="logo"> | |
336 | <h1><span>IPFire</span></h1> | |
337 | <h2>$h2</h2> | |
338 | </div> | |
339 | </div> | |
340 | </div> | |
341 | ||
342 | <div id="main"> | |
343 | <div id="main_inner" class="fixed"> | |
344 | <div id="primaryContent_2columns"> | |
345 | <div id="columnA_2columns"> | |
346 | END | |
347 | ; | |
348 | } | |
349 | ||
350 | sub closepage () { | |
351 | my $status = &connectionstatus(); | |
352 | $uptime = `/usr/bin/uptime`; | |
353 | ||
354 | print <<END | |
355 | </div> | |
356 | </div> | |
357 | ||
358 | <div id="secondaryContent_2columns"> | |
359 | ||
360 | <div id="columnC_2columns"> | |
361 | END | |
362 | ; | |
363 | &showsubsection($menu); | |
364 | &showsubsubsection($menu); | |
365 | ||
366 | print <<END | |
367 | </div> | |
368 | </div> | |
369 | ||
370 | <br class="clear" /> | |
371 | <div id="footer" class="fixed"> | |
372 | <b>Status:</b> $status <b>Uptime:</b>$uptime | |
373 | END | |
374 | ; | |
375 | if ($settings{'SPEED'} ne 'off') { | |
376 | print <<END | |
377 | <br /> | |
378 | <form name='speed'> | |
379 | <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" /> | |
380 | $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"/> | |
381 | </form> | |
382 | END | |
383 | ; | |
384 | } | |
385 | print <<END | |
386 | </div> | |
387 | </div> | |
388 | </div> | |
389 | </body> | |
390 | </html> | |
391 | END | |
392 | ; | |
393 | } | |
394 | ||
395 | sub openbigbox | |
396 | { | |
397 | } | |
398 | ||
399 | sub closebigbox | |
400 | { | |
401 | } | |
402 | ||
403 | sub openbox | |
404 | { | |
405 | $width = $_[0]; | |
406 | $align = $_[1]; | |
407 | $caption = $_[2]; | |
408 | ||
409 | print <<END | |
410 | <!-- openbox --> | |
411 | <div class="post" align="$align"> | |
412 | END | |
413 | ; | |
414 | ||
415 | if ($caption) { print "<h3>$caption</h3>\n"; } else { print " "; } | |
416 | } | |
417 | ||
418 | sub closebox | |
419 | { | |
420 | print <<END | |
421 | </div> | |
422 | <br class="clear" /> | |
423 | <!-- closebox --> | |
424 | END | |
425 | ; | |
426 | } | |
427 | ||
428 | 1; |