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