From: Alf Høgemark Date: Sat, 22 Feb 2014 14:23:39 +0000 (+0100) Subject: index.cgi: Make html valid, and improve dialup and vpn display X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=commitdiff_plain;h=c010871ab16111a57d518406c188e43837799600 index.cgi: Make html valid, and improve dialup and vpn display Make the html validate. One part of the changes is to move style from using deprecated attributes to using style attribute on tag. The other part is to make sure that tables, rows and cells are properly closed and nested. Use a table for showing output from the dialctrl script. --- diff --git a/html/cgi-bin/index.cgi b/html/cgi-bin/index.cgi index ca98e7211..f22964b02 100644 --- a/html/cgi-bin/index.cgi +++ b/html/cgi-bin/index.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2012 IPFire Team # +# Copyright (C) 2007-2014 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -166,18 +166,22 @@ if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( print < - - - - - - - +
$Lang::tr{'network'}$Lang::tr{'ip address'}$Lang::tr{'status'}
$Lang::tr{'internet'}
$ipaddr $connstate
+ + + + + + + + + + END my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0]; if ( "$HOSTNAME" ne "" ) { print < + END } @@ -187,7 +191,7 @@ END chomp($GATEWAY); close TMP; print < + END } @@ -209,99 +213,131 @@ END - - +
$Lang::tr{'network'}$Lang::tr{'ip address'}$Lang::tr{'status'}
$Lang::tr{'internet'}
$ipaddr $connstate
$Lang::tr{'hostname'}:$HOSTNAME
$Lang::tr{'hostname'}:$HOSTNAME$Lang::tr{'gateway'}:$GATEWAY
$Lang::tr{'gateway'}:$GATEWAY
$Lang::tr{'dns servers'}: + $dns_servers_str
END #Dial profiles if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){ -print `/usr/local/bin/dialctrl.pl show`; -print < - + # The dialctrl.pl script outputs html + print `/usr/local/bin/dialctrl.pl show`; + if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) { + print < +
+ + +
$Lang::tr{'profile'}: -
-
- - -
- -
-
- -
-
+ + + +
+ + + + + +
+
+ +
+
+
+ +
+
+
END } else { - print "$Lang::tr{'profile has errors'}\n \n"; + print "
$Lang::tr{'profile has errors'}
"; } - print""; } - if ( $netsettings{'GREEN_DEV'} ) { + + +print < + + + + + + +END + +if ( $netsettings{'GREEN_DEV'} ) { my $sub=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'}); print < -
$Lang::tr{'network'}$Lang::tr{'ip address'}$Lang::tr{'status'}
- - - - - + + '; + print ''; } - if ( $netsettings{'BLUE_DEV'} ) { +if ( $netsettings{'BLUE_DEV'} ) { my $sub=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'}); print < + + '; + print ''; } - if ( $netsettings{'ORANGE_DEV'} ) { +if ( $netsettings{'ORANGE_DEV'} ) { my $sub=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'}); print < + + + + END } #check if IPSEC is running if ( $vpnsettings{'ENABLED'} eq 'on' || $vpnsettings{'ENABLED_BLUE'} eq 'on' ) { my $ipsecip = $vpnsettings{'VPN_IP'}; print< + + + + END } @@ -317,14 +353,15 @@ if (($confighash{'ENABLED'} eq "on") || $ovpnip="$ovpnip/$sub"; print < - - + + END } -print"
$Lang::tr{'network'}$Lang::tr{'ip address'}$Lang::tr{'status'}
$Lang::tr{'lan'} - $netsettings{'GREEN_ADDRESS'}/$sub - + + $Lang::tr{'lan'} + $netsettings{'GREEN_ADDRESS'}/$sub END if ( $proxysettings{'ENABLE'} eq 'on' ) { print $Lang::tr{'advproxy on'}; if ( $proxysettings{'TRANSPARENT'} eq 'on' ) { print " (transparent)"; } } else { print $Lang::tr{'advproxy off'}; } + print '
$Lang::tr{'wireless'}
-
$netsettings{'BLUE_ADDRESS'}/$sub - +
+ $Lang::tr{'wireless'} + $netsettings{'BLUE_ADDRESS'}/$sub + END if ( $proxysettings{'ENABLE_BLUE'} eq 'on' ) { print $Lang::tr{'advproxy on'}; if ( $proxysettings{'TRANSPARENT_BLUE'} eq 'on' ) { print " (transparent)"; } } else { print $Lang::tr{'advproxy off'}; } + print '
$Lang::tr{'dmz'}
-
$netsettings{'ORANGE_ADDRESS'}/$sub - Online +
+ $Lang::tr{'dmz'} + $netsettings{'ORANGE_ADDRESS'}/$subOnline
$Lang::tr{'ipsec'}
-
$ipsecip - Online +
+ $Lang::tr{'ipsec'} + $ipsecipOnline
- OpenVPN
+
+ OpenVPN $ovpnip - Online + $ovpnipOnline
"; +print""; &Header::closebox(); #Check if there are any vpns configured (ipsec and openvpn) @@ -348,7 +385,8 @@ foreach my $dkey (sort { ncmp($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpn if ($showbox){ # Start of Box wich contains all vpn connections &Header::openbox('100%', 'center', $Lang::tr{'vpn'}); -#show ipsec connectiontable + + #show ipsec connectiontable if ( $showipsec ) { my $ipsecip = $vpnsettings{'VPN_IP'}; my @status = `/usr/local/bin/ipsecctrl I`; @@ -358,12 +396,11 @@ if ($showbox){ my $col=""; my $count=0; print < - +
- - - + + + END foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) { @@ -373,43 +410,43 @@ END $vpnsub=&General::iporsubtocidr($vpnsub); $vpnip="$vpnip/$vpnsub"; if ($count % 2){ - $col="bgcolor='$color{'color22'}'"; + $col = $color{'color22'}; }else{ - $col="bgcolor='$color{'color20'}'"; - } - if ($id % 2) { - print ""; - } else { - print ""; + $col = $color{'color20'}; } - my $active = ""; + print ""; + print ""; + print ""; + + my $activecolor = $Header::colourred; + my $activestatus = $Lang::tr{'capsclosed'}; if ($vpnconfig{$key}[0] eq 'off') { - $active = ""; + $activecolor = $Header::colourblue; + $activestatus = $Lang::tr{'capsclosed'}; } else { foreach my $line (@status) { if (($line =~ /\"$vpnconfig{$key}[1]\".*IPsec SA established/) || ($line =~/$vpnconfig{$key}[1]\{.*INSTALLED/ )){ - $active = ""; + $activecolor = $Header::colourgreen; + $activestatus = $Lang::tr{'capsopen'}; } } } - print "$active"; + print ""; + print ""; } } - print "
$Lang::tr{'ipsec network'}$Lang::tr{'ip address'}$Lang::tr{'status'}$Lang::tr{'ipsec network'}$Lang::tr{'ip address'}$Lang::tr{'status'}
$vpnconfig{$key}[1]$vpnip
$vpnconfig{$key}[1]$vpnip$Lang::tr{'capsclosed'}
$vpnconfig{$key}[1]$vpnip$Lang::tr{'capsclosed'}$Lang::tr{'capsopen'}$activestatus
"; + print ""; } -### -# Check if there is any OpenVPN connection configured. -### - + # Check if there is any OpenVPN connection configured. if ( $showovpn ){ print < - +
+
- - - + + + END # Check if the OpenVPN server for Road Warrior Connections is running and display status information. @@ -436,9 +473,9 @@ END $display = $tustate[1]; } if ($count %2){ - $col="bgcolor='$color{'color22'}'"; + $col = $color{'color22'}; }else{ - $col="bgcolor='$color{'color20'}'"; + $col = $color{'color20'}; } $active='off'; #make cidr from ip @@ -447,16 +484,16 @@ END my $vpnip="$vpnip/$vpnsub"; print < - - - + + + END } } } if ($active ne 'off'){ - print ""; + print ""; } print"
$Lang::tr{'openvpn network'}$Lang::tr{'ip address'}$Lang::tr{'status'}$Lang::tr{'openvpn network'}$Lang::tr{'ip address'}$Lang::tr{'status'}$ovpnconfig{$dkey}[1]$vpnip$display$ovpnconfig{$dkey}[1]$vpnip$display
$Lang::tr{'ovpn no connections'}
$Lang::tr{'ovpn no connections'}
"; } @@ -476,7 +513,7 @@ $free[2] =~ m/(\d+)/; my $used = $1; my $pct = int 100 * ($mem - $used) / $mem; if ($used / $mem > 90) { - $warnmessage .= "
  • $Lang::tr{'high memory usage'}: $pct% !
  • \n"; + $warnmessage .= "
  • $Lang::tr{'high memory usage'}: $pct% !
  • "; } # Diskspace usage warning @@ -491,7 +528,7 @@ foreach my $line (@df) { if ($1<5) { # available:plain value in MB, and not %used as 10% is too much to waste on small disk # and root size should not vary during time - $warnmessage .= "
  • $Lang::tr{'filesystem full'}: $temp[0] $Lang::tr{'free'}=$1M !
  • \n"; + $warnmessage .= "
  • $Lang::tr{'filesystem full'}: $temp[0] $Lang::tr{'free'}=$1M !
  • "; } } else { @@ -500,7 +537,7 @@ foreach my $line (@df) { if ($1>90) { @temp = split(/ /,$line); $temp2=int(100-$1); - $warnmessage .= "
  • $Lang::tr{'filesystem full'}: $temp[0] $Lang::tr{'free'}=$temp2% !
  • \n"; + $warnmessage .= "
  • $Lang::tr{'filesystem full'}: $temp[0] $Lang::tr{'free'}=$temp2% !
  • "; } } } @@ -512,7 +549,7 @@ foreach my $file (@files) { my $disk=`echo $file | cut -d"-" -f2`; chomp ($disk); if (`/bin/grep "SAVE ALL DATA" $file`) { - $warnmessage .= "
  • $Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !
  • \n\n"; + $warnmessage .= "
  • $Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !
  • "; } } @@ -520,24 +557,25 @@ foreach my $file (@files) { my @files = `mount | grep " reiser4 (" 2>/dev/null`; foreach my $disk (@files) { chomp ($disk); - $warnmessage .= "
  • $disk - $Lang::tr{'deprecated fs warn'}
  • \n\n"; + $warnmessage .= "
  • $disk - $Lang::tr{'deprecated fs warn'}
  • "; } if ($warnmessage) { &Header::openbox('100%','center', ); - print ""; + print "
    "; print ""; - print "
    $Lang::tr{'fwhost hint'}
    $warnmessage
    "; + print "$warnmessage"; + print ""; &Header::closebox(); } -print "
    "; &Pakfire::dblist("upgrade", "notice"); if ( -e "/var/run/need_reboot" ) { - print "

    $Lang::tr{'needreboot'}!"; + print "
    "; + print "

    $Lang::tr{'needreboot'}!"; + print "
    "; } -print "
    "; - &Header::closebigbox(); &Header::closepage(); + diff --git a/src/scripts/dialctrl.pl b/src/scripts/dialctrl.pl index 88f54924b..b0abab7b1 100644 --- a/src/scripts/dialctrl.pl +++ b/src/scripts/dialctrl.pl @@ -162,8 +162,10 @@ else { print <$Lang::tr{'since'} $update -$Lang::tr{'connections'}: $up | $Lang::tr{'disconnects'}: $down | $Lang::tr{'attemps'}: $rec -$Lang::tr{'total connection time'}:$current ~ $ontime% + + + +
    $Lang::tr{'connections'}: $up$Lang::tr{'disconnects'}: $down$Lang::tr{'attemps'}: $rec
    $Lang::tr{'total connection time'}:$current ~ $ontime%
    END ; }