]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/html/themes/ipfire/include/functions.pl
suricata: Change midstream policy to "pass-flow"
[people/pmueller/ipfire-2.x.git] / html / html / themes / ipfire / include / functions.pl
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 # Theme file for IPfire (based on ipfire theme) #
23 # Author kay-michael köhler kmk <michael@koehler.tk> #
24 # #
25 # Version 1.0 March, 6th 2013 #
26 ###############################################################################
27 # #
28 # Modyfied theme by a.marx@ipfire.org January 2014 #
29 # #
30 # Cleanup code, deleted unused code and rewrote the rest to get a new working #
31 # IPFire default theme. #
32 ###############################################################################
33
34 ###############################################################################
35 #
36 # print menu html elements for submenu entries
37 # @param submenu entries
38 sub showsubmenu() {
39 my $submenus = shift;
40
41 print "<ul>";
42 foreach my $item (sort keys %$submenus) {
43 $link = getlink($submenus->{$item});
44 next if (!is_menu_visible($link) or $link eq '');
45
46 my $subsubmenus = $submenus->{$item}->{'subMenu'};
47
48 if ($subsubmenus) {
49 print '<li class="has-sub ">';
50 } else {
51 print '<li>';
52 }
53 print '<a href="'.$link.'">'.$submenus->{$item}->{'caption'}.'</a>';
54
55 &showsubmenu($subsubmenus) if ($subsubmenus);
56 print '</li>';
57 }
58 print "</ul>"
59 }
60
61 ###############################################################################
62 #
63 # print menu html elements
64 sub showmenu() {
65 print '<div id="cssmenu" class="bigbox fixed">';
66
67 if ($settings{'SPEED'} ne 'off') {
68 print <<EOF;
69 <div id='traffic'>
70 <strong>$Lang::tr{'traffic stat title'}:</strong>
71 $Lang::tr{'traffic stat in'} <span id='rx_kbs'>--.-- bit/s</span> &nbsp;
72 $Lang::tr{'traffic stat out'} <span id='tx_kbs'>--.-- bit/s</span>
73 </div>
74 EOF
75 }
76
77 print "<ul>";
78 foreach my $k1 ( sort keys %$menu ) {
79 $link = getlink($menu->{$k1});
80 next if (!is_menu_visible($link) or $link eq '');
81 print '<li class="has-sub "><a href="#"><span>'.$menu->{$k1}->{'caption'}.'</span></a>';
82 my $submenus = $menu->{$k1}->{'subMenu'};
83 &showsubmenu($submenus) if ($submenus);
84 print "</li>";
85 }
86
87 print "</ul></div>";
88 }
89
90 ###############################################################################
91 #
92 # print page opening html layout
93 # @param page title
94 # @param boh
95 # @param extra html code for html head section
96 # @param suppress menu option, can be numeric 1 or nothing.
97 # menu will be suppressed if param is 1
98 sub openpage {
99 my $title = shift;
100 my $boh = shift;
101 my $extrahead = shift;
102 my $suppressMenu = shift // 0;
103
104 my $headline = "IPFire";
105 if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) {
106 $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
107 }
108
109 print <<END;
110 <!DOCTYPE html>
111 <html lang="$language">
112 <head>
113 <title>$headline - $title</title>
114 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
115 <link rel="shortcut icon" href="/favicon.ico" />
116 <script type="text/javascript" src="/include/jquery.js"></script>
117 <script src="/include/rrdimage.js"></script>
118
119 $extrahead
120 <script type="text/javascript">
121 function swapVisibility(id) {
122 \$('#' + id).toggle();
123 }
124 </script>
125 END
126
127
128 print "<link href=\"/themes/ipfire/include/css/style.css?v=20240125\" rel=\"stylesheet\" type=\"text/css\" />\n";
129
130
131 if ($settings{'SPEED'} ne 'off') {
132 print <<END
133 <script type="text/javascript" src="/themes/ipfire/include/js/refreshInetInfo.js"></script>
134 END
135 ;
136 }
137
138 print <<END
139 </head>
140 <body>
141 <div id="header" class="fixed">
142 <div id="logo">
143 <h1>
144 <a href="https://www.ipfire.org">
145 IPFire_
146 </a>
147 END
148 ;
149 if ($settings{'WINDOWWITHHOSTNAME'} ne 'off') {
150 print "&dash; $settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
151 }
152
153 print <<END
154 </h1>
155 </div>
156 </div>
157 END
158 ;
159
160 unless($suppressMenu) {
161 &genmenu();
162 &showmenu();
163 }
164
165 print <<END
166 <div class="bigbox fixed">
167 <div id="main_inner" class="fixed">
168 <div id="main_header">
169 <h1>$title</h1>
170 END
171 ;
172
173 # Print user manual link
174 my $manual_url = &Header::get_manualpage_url();
175 if($manual_url) {
176 print <<END
177 <span><a href="$manual_url" title="$Lang::tr{'online help en'}" target="_blank"><img src="/images/help-browser.png" alt="$Lang::tr{'online help en'}"></a></span>
178 END
179 ;
180 }
181
182 print <<END
183 </div>
184 END
185 ;
186 }
187
188 ###############################################################################
189 #
190 # print page opening html layout without menu
191 # @param page title
192 # @param boh
193 # @param extra html code for html head section
194 sub openpagewithoutmenu {
195 openpage(shift,shift,shift,1);
196 return;
197 }
198
199 ###############################################################################
200 #
201 # print page closing html layout
202
203 sub closepage () {
204 open(FILE, "</etc/system-release");
205 my $system_release = <FILE>;
206 $system_release =~ s/core/$Lang::tr{'core update'} /;
207 close(FILE);
208
209 print <<END;
210 </div>
211 </div>
212
213 <div id="footer" class='bigbox fixed'>
214 <span class="pull-right">
215 <a href="https://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> &bull;
216 <a href="https://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a>
217 </span>
218
219 <strong>$system_release</strong>
220 </div>
221 </body>
222 </html>
223 END
224 ;
225 }
226
227 ###############################################################################
228 #
229 # print big box opening html layout
230 sub openbigbox {
231 }
232
233 ###############################################################################
234 #
235 # print big box closing html layout
236 sub closebigbox {
237 }
238
239 ###############################################################################
240 #
241 # print box opening html layout
242 # @param page width
243 # @param page align
244 # @param page caption
245 sub openbox {
246 $width = $_[0];
247 $align = $_[1];
248 $caption = $_[2];
249
250 if($align eq 'center') {
251 print "<div class='post' align='center'>\n"
252 }
253 else {
254 print "<div class='post'>\n";
255 }
256
257 if ($caption) {
258 print "<h2>$caption</h2>\n";
259 }
260 }
261
262 ###############################################################################
263 #
264 # print box closing html layout
265 sub closebox {
266 print "</div>";
267 }