]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/index.cgi
index.cgi: Make html valid, and improve dialup and vpn display
[ipfire-2.x.git] / html / cgi-bin / index.cgi
CommitLineData
ac1cfefa 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
c010871a 5# Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
70df8302
MT
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###############################################################################
ac1cfefa
MT
21
22use strict;
54fd0535 23use Net::Telnet;
9d386698 24use Sort::Naturally;
ac1cfefa
MT
25
26# enable only the following on debugging purpose
cb5e9c6c
CS
27#use warnings;
28#use CGI::Carp 'fatalsToBrowser';
ac1cfefa 29
e383179b 30require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
31require "${General::swroot}/lang.pl";
32require "${General::swroot}/header.pl";
2b38ab5c 33require "/opt/pakfire/lib/functions.pl";
ac1cfefa
MT
34
35my %cgiparams=();
36my %pppsettings=();
37my %modemsettings=();
38my %netsettings=();
39my %ddnssettings=();
9d386698
AM
40my %proxysettings=();
41my %vpnsettings=();
42my %vpnconfig=();
43my %ovpnconfig=();
ac1cfefa 44my $warnmessage = '';
c85ec3b4 45my $refresh = "";
e383179b 46my $ipaddr='';
9d386698
AM
47my $showbox=0;
48my $showipsec=0;
49my $showovpn=0;
50
51if ( ! -e "/var/ipfire/main/gpl_accepted" ) {
52 print "Status: 302 Moved Temporarily\n";
53 print "Location: gpl.cgi\n\n";
54 exit (0);
55}
337305ef 56
ac1cfefa
MT
57&Header::showhttpheaders();
58
59$cgiparams{'ACTION'} = '';
60&Header::getcgihash(\%cgiparams);
61$pppsettings{'VALID'} = '';
62$pppsettings{'PROFILENAME'} = 'None';
63&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
64&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
65&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
66&General::readhash("${General::swroot}/ddns/settings", \%ddnssettings);
9d386698
AM
67&General::readhash("${General::swroot}/proxy/advanced/settings", \%proxysettings);
68&General::readhash("${General::swroot}/vpn/settings", \%vpnsettings);
ac1cfefa 69
f2fdd0c1
CS
70my %color = ();
71my %mainsettings = ();
72&General::readhash("${General::swroot}/main/settings", \%mainsettings);
73&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
74
ac1cfefa 75my $connstate = &Header::connectionstatus();
56b7a3e2 76
9d386698
AM
77if ( -e "/var/ipfire/main/gpl-accepted" ) {
78 if ($connstate =~ /$Lang::tr{'connecting'}/ || /$Lang::tr{'connection closed'}/ ){
79 $refresh = "<meta http-equiv='refresh' content='5;'>";
80 }elsif ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") {
81 $refresh = "<meta http-equiv='refresh' content='30;'>";
82 }
f341a168 83}
ac1cfefa 84
957363eb
CS
85if ($cgiparams{'ACTION'} eq $Lang::tr{'dial profile'})
86{
87 my $profile = $cgiparams{'PROFILE'};
88 my %tempcgiparams = ();
89 $tempcgiparams{'PROFILE'} = '';
90 &General::readhash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
91 \%tempcgiparams);
92
93 # make a link from the selected profile to the "default" one.
94 unlink("${General::swroot}/ppp/settings");
95 link("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
96 "${General::swroot}/ppp/settings");
9d386698
AM
97 open (TMP, ">${General::swroot}/ppp/updatesettings");
98 close TMP;
957363eb
CS
99 # read in the new params "early" so we can write secrets.
100 %cgiparams = ();
101 &General::readhash("${General::swroot}/ppp/settings", \%cgiparams);
102 $cgiparams{'PROFILE'} = $profile;
103 $cgiparams{'BACKUPPROFILE'} = $profile;
104 &General::writehash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
105 \%cgiparams);
106
107 # write secrets file.
108 open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
109 flock(FILE, 2);
110 my $username = $cgiparams{'USERNAME'};
111 my $password = $cgiparams{'PASSWORD'};
112 print FILE "'$username' * '$password'\n";
113 chmod 0600, "${General::swroot}/ppp/secrets";
114 close FILE;
115
116 &General::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}");
117 $cgiparams{'ACTION'} = "$Lang::tr{'dial'}";
118}
119
120if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) {
a56b5be4 121 system('/usr/local/bin/redctrl start > /dev/null') == 0
9d386698
AM
122 or &General::log("Dial failed: $?"); sleep 1;
123}elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) {
a56b5be4 124 system('/usr/local/bin/redctrl stop > /dev/null') == 0
9d386698
AM
125 or &General::log("Hangup failed: $?"); sleep 1;
126}
957363eb 127
e383179b
MT
128my $c;
129my $maxprofiles = 5;
130my @profilenames = ();
131
132for ($c = 1; $c <= $maxprofiles; $c++)
133{
134 my %temppppsettings = ();
135 $temppppsettings{'PROFILENAME'} = '';
136 &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings);
137 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
138}
139my %selected;
140for ($c = 1; $c <= $maxprofiles; $c++) {
141 $selected{'PROFILE'}{$c} = '';
142}
143$selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
144my $dialButtonDisabled = "disabled='disabled'";
145
ac1cfefa
MT
146&Header::openpage($Lang::tr{'main page'}, 1, $refresh);
147&Header::openbigbox('', 'center');
9d386698
AM
148if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) {
149 $ipaddr = <IPADDR>;
150 close IPADDR;
151 chomp ($ipaddr);
152 }
ac1cfefa 153
043cfbc0 154&Header::openbox('100%', 'center', '');
a08a5f33 155if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) {
986e08d9
MT
156 if (open(IPADDR,"${General::swroot}/ddns/ipcache")) {
157 $ipaddr = <IPADDR>;
158 close IPADDR;
159 chomp ($ipaddr);
160 }
ac1cfefa
MT
161} elsif ($modemsettings{'VALID'} eq 'no') {
162 print "$Lang::tr{'modem settings have errors'}\n </b></font>\n";
163} else {
164 print "$Lang::tr{'profile has errors'}\n </b></font>\n";
165}
166
a56b5be4 167print <<END;
e383179b 168<!-- Table of networks -->
c010871a
AH
169<table class='tbl' style='width:80%;'>
170 <tr>
171 <th style='background-color:$color{'color20'};'>$Lang::tr{'network'}</th>
172 <th style='background-color:$color{'color20'};'>$Lang::tr{'ip address'}</th>
173 <th style='background-color:$color{'color20'};'>$Lang::tr{'status'}</th>
174 </tr>
175 <tr>
176 <td style='width:25%; text-align:center; background-color:$Header::colourred;'><a href='/cgi-bin/pppsetup.cgi' style='color:white;'><b>$Lang::tr{'internet'}</b></a><br/></td>
177 <td style='width:30%; text-align:center;'>$ipaddr </td>
178 <td style='width:45%; text-align:center;'>$connstate </td>
179 </tr>
f3bbb213 180END
043cfbc0
AM
181 my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0];
182 if ( "$HOSTNAME" ne "" ) {
183 print <<END;
c010871a 184 <tr><td><b>$Lang::tr{'hostname'}:</b><td style='text-align:center;'>$HOSTNAME</td><td></td>
043cfbc0
AM
185END
186 }
187
9d386698
AM
188 if ( -e "${General::swroot}/red/remote-ipaddress" ) {
189 open (TMP, "<${General::swroot}/red/remote-ipaddress");
190 my $GATEWAY = <TMP>;
043cfbc0 191 chomp($GATEWAY);
9d386698 192 close TMP;
043cfbc0 193 print <<END;
c010871a 194 <tr><td><b>$Lang::tr{'gateway'}:</b><td style='text-align:center;'>$GATEWAY</td><td></td></tr>
043cfbc0
AM
195END
196 }
317638e7
MT
197
198 my @dns_servers = ();
199 foreach my $f ("${General::swroot}/red/dns1", "${General::swroot}/red/dns2") {
200 open(DNS, "<$f");
201 my $dns_server = <DNS>;
202 close(DNS);
203
204 chomp($dns_server);
205 if ($dns_server) {
206 push(@dns_servers, $dns_server);
207 }
208 }
209 my $dns_servers_str = join(", ", @dns_servers);
043cfbc0 210
125b6fcd
MT
211 print <<END;
212 <tr>
213 <td>
317638e7 214 <b>$Lang::tr{'dns servers'}:</b>
125b6fcd 215 </td>
c010871a 216 <td style='text-align:center;'>
317638e7 217 $dns_servers_str
125b6fcd 218 </td>
c010871a 219 <td></td>
125b6fcd 220 </tr>
043cfbc0
AM
221 </table>
222END
043cfbc0
AM
223
224#Dial profiles
c85ec3b4 225if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){
c010871a
AH
226 # The dialctrl.pl script outputs html
227 print `/usr/local/bin/dialctrl.pl show`;
228 if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
229 print <<END;
230 <br/>
231 <table style='width:80%;'>
043cfbc0 232 <tr><td>
957363eb 233 <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}:
e383179b
MT
234 <select name='PROFILE'>
235END
c010871a
AH
236 for ($c = 1; $c <= $maxprofiles; $c++)
237 {
238 if ($profilenames[$c] ne '') {
239 $dialButtonDisabled = "";
240 print "<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>";
241 }
e383179b 242 }
c010871a 243 $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active");
e383179b 244 print <<END;
c010871a
AH
245 </select>
246 <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled />
247 </form>
248 </td>
249 <td style='text-align:center;'>
250 <table style='width:100%;'>
251 <tr>
252 <td style='width=50%; text-align:right;'>
253 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
254 <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'>
255 </form>
256 </td>
257 <td style='width=50%; text-align:left;'>
258 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
259 <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'>
260 </form>
261 </td>
262 </tr>
263 </table>
264 </td>
265 </tr>
266 </table>
e383179b
MT
267END
268 } else {
c010871a 269 print "<br/><span style='color:red;'>$Lang::tr{'profile has errors'}</span><br/>";
e383179b 270 }
c85ec3b4 271}
c010871a
AH
272
273
274print <<END;
275<br/>
276<table class='tbl' style='width:80%;'>
277<tr>
278 <th>$Lang::tr{'network'}</th>
279 <th>$Lang::tr{'ip address'}</th>
280 <th>$Lang::tr{'status'}</th>
281</tr>
282END
283
284if ( $netsettings{'GREEN_DEV'} ) {
043cfbc0 285 my $sub=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'});
786f2c8a 286 print <<END;
043cfbc0 287 <tr>
c010871a
AH
288 <td style='width:25%; text-align:center; background-color:$Header::colourgreen;'>
289 <a href='/cgi-bin/dhcp.cgi' style='color:white'><b>$Lang::tr{'lan'}</b></a>
290 </td>
291 <td style='width:30%; text-align:center;'>$netsettings{'GREEN_ADDRESS'}/$sub</td>
292 <td style='width:45%; text-align:center;'>
e383179b 293END
9d386698
AM
294 if ( $proxysettings{'ENABLE'} eq 'on' ) {
295 print $Lang::tr{'advproxy on'};
296 if ( $proxysettings{'TRANSPARENT'} eq 'on' ) { print " (transparent)"; }
ef482d53 297 } else { print $Lang::tr{'advproxy off'}; }
c010871a
AH
298 print '</td>';
299 print '</tr>';
072cd997 300 }
c010871a 301if ( $netsettings{'BLUE_DEV'} ) {
043cfbc0
AM
302 my $sub=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'});
303 print <<END;
c010871a
AH
304 <tr>
305 <td style='width:25%; text-align:center; background-color:$Header::colourblue;'>
306 <a href='/cgi-bin/wireless.cgi' style='color:white'><b>$Lang::tr{'wireless'}</b></a>
307 </td>
308 <td style='width:30%; text-align:center;'>$netsettings{'BLUE_ADDRESS'}/$sub
309 <td style='width:45%; text-align:center;'>
e383179b 310END
9d386698
AM
311 if ( $proxysettings{'ENABLE_BLUE'} eq 'on' ) {
312 print $Lang::tr{'advproxy on'};
313 if ( $proxysettings{'TRANSPARENT_BLUE'} eq 'on' ) { print " (transparent)"; }
ef482d53 314 } else { print $Lang::tr{'advproxy off'}; }
c010871a
AH
315 print '</td>';
316 print '</tr>';
072cd997 317 }
c010871a 318if ( $netsettings{'ORANGE_DEV'} ) {
043cfbc0
AM
319 my $sub=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'});
320 print <<END;
c010871a
AH
321 <tr>
322 <td style='width:25%; text-align:center; background-color:$Header::colourorange;'>
323 <a href='/cgi-bin/firewall.cgi' style='color:white'><b>$Lang::tr{'dmz'}</b></a>
324 </td>
325 <td style='width:30%; text-align:center;'>$netsettings{'ORANGE_ADDRESS'}/$sub</td>
326 <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td>
327 </tr>
043cfbc0
AM
328END
329 }
330#check if IPSEC is running
9d386698
AM
331if ( $vpnsettings{'ENABLED'} eq 'on' || $vpnsettings{'ENABLED_BLUE'} eq 'on' ) {
332 my $ipsecip = $vpnsettings{'VPN_IP'};
043cfbc0 333print<<END;
c010871a
AH
334 <tr>
335 <td style='width:25%; text-align:center; background-color:$Header::colourvpn;'>
336 <a href='/cgi-bin/vpnmain.cgi' style='color:white'><b>$Lang::tr{'ipsec'}</b></a>
337 </td>
338 <td style='width:30%; text-align:center;'>$ipsecip</td>
339 <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td>
340 </tr>
043cfbc0
AM
341END
342}
343
344#check if OpenVPN is running
345my %confighash=();
346&General::readhash("${General::swroot}/ovpn/settings", \%confighash);
347
348if (($confighash{'ENABLED'} eq "on") ||
349 ($confighash{'ENABLED_BLUE'} eq "on") ||
350 ($confighash{'ENABLED_ORANGE'} eq "on")) {
351 my ($ovpnip,$sub) = split("/",$confighash{'DOVPN_SUBNET'});
352 $sub=&General::iporsubtocidr($sub);
353 $ovpnip="$ovpnip/$sub";
043cfbc0
AM
354print <<END;
355 <tr>
c010871a
AH
356 <td style='width:25%; text-align:center; background-color:$Header::colourvpn;'>
357 <a href='/cgi-bin/ovpnmain.cgi' style='color:white'><b>OpenVPN</b></a>
043cfbc0 358 </td>
c010871a
AH
359 <td style='width:30%; text-align:center;'>$ovpnip</td>
360 <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td>
361 </tr>
e383179b 362END
072cd997 363 }
c010871a 364print"</table>";
043cfbc0
AM
365&Header::closebox();
366
9d386698
AM
367#Check if there are any vpns configured (ipsec and openvpn)
368&General::readhasharray("${General::swroot}/vpn/config", \%vpnconfig);
369foreach my $key (sort { ncmp($vpnconfig{$a}[1],$vpnconfig{$b}[1]) } keys %vpnconfig) {
370 if ($vpnconfig{$key}[0] eq 'on'){
371 $showipsec=1;
372 $showbox=1;
373 last;
374 }
375}
376&General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfig);
377foreach my $dkey (sort { ncmp($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpnconfig) {
378 if (($ovpnconfig{$dkey}[3] eq 'net') && (-e "/var/run/$ovpnconfig{$dkey}[1]n2n.pid")){
379 $showbox=1;
380 $showovpn=1;
381 last;
382 }
383}
043cfbc0 384
9d386698
AM
385if ($showbox){
386# Start of Box wich contains all vpn connections
387 &Header::openbox('100%', 'center', $Lang::tr{'vpn'});
c010871a
AH
388
389 #show ipsec connectiontable
9d386698
AM
390 if ( $showipsec ) {
391 my $ipsecip = $vpnsettings{'VPN_IP'};
db073a10 392 my @status = `/usr/local/bin/ipsecctrl I`;
e455cafe 393 my %confighash = ();
9d386698
AM
394 my $id = 0;
395 my $gif;
396 my $col="";
397 my $count=0;
072cd997 398 print <<END;
c010871a 399 <table class='tbl' style='width:80%;'>
043cfbc0 400 <tr>
c010871a
AH
401 <th style='width:40%;'>$Lang::tr{'ipsec network'}</th>
402 <th style='width:30%;'>$Lang::tr{'ip address'}</th>
403 <th style='width:30%;'>$Lang::tr{'status'}</th>
043cfbc0 404 </tr>
e383179b 405END
9d386698
AM
406 foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) {
407 if ($vpnconfig{$key}[0] eq 'on') {
408 $count++;
409 my ($vpnip,$vpnsub) = split("/",$vpnconfig{$key}[11]);
410 $vpnsub=&General::iporsubtocidr($vpnsub);
411 $vpnip="$vpnip/$vpnsub";
412 if ($count % 2){
c010871a 413 $col = $color{'color22'};
9d386698 414 }else{
c010871a 415 $col = $color{'color20'};
9d386698 416 }
c010871a
AH
417 print "<tr>";
418 print "<td style='text-align:left; color:white; background-color:$Header::colourovpn;'>$vpnconfig{$key}[1]</td>";
419 print "<td style='text-align:left; background-color:$col'>$vpnip</td>";
420
421 my $activecolor = $Header::colourred;
422 my $activestatus = $Lang::tr{'capsclosed'};
9d386698 423 if ($vpnconfig{$key}[0] eq 'off') {
c010871a
AH
424 $activecolor = $Header::colourblue;
425 $activestatus = $Lang::tr{'capsclosed'};
9d386698
AM
426 } else {
427 foreach my $line (@status) {
428 if (($line =~ /\"$vpnconfig{$key}[1]\".*IPsec SA established/) || ($line =~/$vpnconfig{$key}[1]\{.*INSTALLED/ )){
c010871a
AH
429 $activecolor = $Header::colourgreen;
430 $activestatus = $Lang::tr{'capsopen'};
9d386698
AM
431 }
432 }
e455cafe 433 }
c010871a
AH
434 print "<td style='text-align:center; color:white; background-color:$activecolor;'><b>$activestatus</b></td>";
435 print "</tr>";
e455cafe 436 }
e455cafe 437 }
c010871a 438 print "</table>";
072cd997 439 }
4715ddb3 440
c010871a 441 # Check if there is any OpenVPN connection configured.
9d386698
AM
442 if ( $showovpn ){
443 print <<END;
c010871a
AH
444 <br/>
445 <table class='tbl' style='width:80%;'>
9d386698 446 <tr>
c010871a
AH
447 <th style='width:40%;'>$Lang::tr{'openvpn network'}</th>
448 <th style='width:30%;'>$Lang::tr{'ip address'}</th>
449 <th style='width:30%;'>$Lang::tr{'status'}</th>
4715ddb3 450END
4715ddb3 451
9d386698
AM
452 # Check if the OpenVPN server for Road Warrior Connections is running and display status information.
453 my $active;
454 my $count=0;
455 # Print the OpenVPN N2N connection status.
456 if ( -d "${General::swroot}/ovpn/n2nconf") {
457 my $col="";
458 foreach my $dkey (sort { ncmp ($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpnconfig) {
459 if (($ovpnconfig{$dkey}[3] eq 'net') && (-e "/var/run/$ovpnconfig{$dkey}[1]n2n.pid")){
460 $count++;
461 my $tport = $ovpnconfig{$dkey}[22];
462 next if ($tport eq '');
463 my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport);
464 $tnet->open('127.0.0.1');
465 my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/');
466 my @tustate = split(/\,/, $output[1]);
467 my $display;
468 my $display_colour = $Header::colourred;
469 if ( $tustate[1] eq 'CONNECTED' || ($tustate[1] eq 'WAIT')) {
470 $display_colour = $Header::colourgreen;
471 $display = $Lang::tr{'capsopen'};
472 } else {
473 $display = $tustate[1];
474 }
475 if ($count %2){
c010871a 476 $col = $color{'color22'};
9d386698 477 }else{
c010871a 478 $col = $color{'color20'};
9d386698
AM
479 }
480 $active='off';
481 #make cidr from ip
482 my ($vpnip,$vpnsub) = split("/",$ovpnconfig{$dkey}[11]);
483 my $vpnsub=&General::iporsubtocidr($vpnsub);
484 my $vpnip="$vpnip/$vpnsub";
485 print <<END;
486 <tr>
c010871a
AH
487 <td style='text-align:left; color:white; background-color:$Header::colourovpn;'>$ovpnconfig{$dkey}[1]</td>
488 <td style='text-align:center; background-color:$col'>$vpnip</td>
489 <td style='text-align:center; color:white; background-color:$display_colour' ><b>$display</b></td>
9d386698 490 </tr>
54fd0535 491END
9d386698 492 }
4715ddb3 493 }
acb305f5 494 }
9d386698 495 if ($active ne 'off'){
c010871a 496 print "<tr><td colspan='3' style='text-align:center;'>$Lang::tr{'ovpn no connections'}</td></tr>";
9d386698
AM
497 }
498 print"</table>";
acb305f5 499 }
043cfbc0 500&Header::closebox();
9d386698
AM
501}
502
579a39d0
MT
503# Fireinfo
504if ( ! -e "/var/ipfire/main/send_profile") {
505 $warnmessage .= "<li><a style='color: white;' href='fireinfo.cgi'>$Lang::tr{'fireinfo please enable'}</a></li>";
506}
507
ac1cfefa
MT
508# Memory usage warning
509my @free = `/usr/bin/free`;
510$free[1] =~ m/(\d+)/;
511my $mem = $1;
512$free[2] =~ m/(\d+)/;
513my $used = $1;
514my $pct = int 100 * ($mem - $used) / $mem;
515if ($used / $mem > 90) {
c010871a 516 $warnmessage .= "<li>$Lang::tr{'high memory usage'}: $pct% !</li>";
ac1cfefa
MT
517}
518
519# Diskspace usage warning
520my @temp=();
521my $temp2=();
8955b5a7 522my @df = `/bin/df -B M -P -x rootfs`;
ac1cfefa
MT
523foreach my $line (@df) {
524 next if $line =~ m/^Filesystem/;
525 if ($line =~ m/root/ ) {
526 $line =~ m/^.* (\d+)M.*$/;
527 @temp = split(/ +/,$line);
528 if ($1<5) {
529 # available:plain value in MB, and not %used as 10% is too much to waste on small disk
530 # and root size should not vary during time
c010871a 531 $warnmessage .= "<li>$Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>";
ac1cfefa
MT
532 }
533
534 } else {
535 # $line =~ m/^.* (\d+)m.*$/;
536 $line =~ m/^.* (\d+)\%.*$/;
537 if ($1>90) {
538 @temp = split(/ /,$line);
539 $temp2=int(100-$1);
c010871a 540 $warnmessage .= "<li>$Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>";
ac1cfefa
MT
541 }
542 }
543}
544
c1712013 545# S.M.A.R.T. health warning
73c7eff8 546my @files = `/bin/ls /var/run/smartctl_out_hddtemp-* 2>/dev/null`;
c1712013
AF
547foreach my $file (@files) {
548 chomp ($file);
549 my $disk=`echo $file | cut -d"-" -f2`;
550 chomp ($disk);
551 if (`/bin/grep "SAVE ALL DATA" $file`) {
c010871a 552 $warnmessage .= "<li>$Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>";
c1712013
AF
553 }
554}
555
b81b96d2
AF
556# Reiser4 warning
557my @files = `mount | grep " reiser4 (" 2>/dev/null`;
558foreach my $disk (@files) {
559 chomp ($disk);
c010871a 560 $warnmessage .= "<li>$disk - $Lang::tr{'deprecated fs warn'}</li>";
b81b96d2
AF
561}
562
ac1cfefa 563if ($warnmessage) {
9d386698 564 &Header::openbox('100%','center', );
c010871a 565 print "<table class='tbl' style='width:80%;'>";
9d386698 566 print "<tr><th>$Lang::tr{'fwhost hint'}</th></tr>";
c010871a
AH
567 print "<tr><td style='color:white; background-color:$Header::colourred;'>$warnmessage</td></tr>";
568 print "</table>";
9d386698 569 &Header::closebox();
ac1cfefa 570}
9d386698 571
2b38ab5c 572&Pakfire::dblist("upgrade", "notice");
f341a168 573if ( -e "/var/run/need_reboot" ) {
c010871a
AH
574 print "<div style='text-align:center; color:red;'>";
575 print "<br/><br/>$Lang::tr{'needreboot'}!";
576 print "</div>";
337305ef 577}
7fa7c7dd 578
ac1cfefa 579&Header::closebigbox();
ac1cfefa 580&Header::closepage();
c010871a 581