[v2,1/2] dhcp.cgi: Fix for bug#10629 - update bgcolor to css

Message ID 20230302141123.3452532-1-adolf.belka@ipfire.org
State Accepted
Commit de4dea96aa9a45785e7bb64aadf14f97cfc1a359
Headers
Series [v2,1/2] dhcp.cgi: Fix for bug#10629 - update bgcolor to css |

Commit Message

Adolf Belka March 2, 2023, 2:11 p.m. UTC
  - This v2 version moves the extraHead variable to header.pl as many of the css values
   will be used in many other WUI cgi pages so makes sense to not define anew in every
   location using the bgcolor or other colour variables.
- I will submit patches to follow the same approach in all other WUI cgi pages once this
   has been submitted into next
- bgcolor was deprecated in HTML 4.01 and is not supported by HTML 5
- The orange colour for IP's that are outside the IPFire green and blue subnets does not
   work on any browser I am using.
- I used the CSS approach that @Leo used in the Zone Configuration cgi page
- This patch changes all existing bgcolor entries to the css based background-color
- Tested on my vm testbed and confirmed to work. The Orange colour for IP's outside of
   the subnet now shows up.

Fixes: Bug#10629
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 config/cfgroot/header.pl | 17 +++++++++++++++++
 html/cgi-bin/dhcp.cgi    | 23 ++++++++++++-----------
 2 files changed, 29 insertions(+), 11 deletions(-)
  

Comments

Bernhard Bitsch March 3, 2023, 6:11 p.m. UTC | #1
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Tested-by: Bernhard Bitsch <bbitsch@ipfire.org>

Am 02.03.2023 um 15:11 schrieb Adolf Belka:
> - This v2 version moves the extraHead variable to header.pl as many of the css values
>     will be used in many other WUI cgi pages so makes sense to not define anew in every
>     location using the bgcolor or other colour variables.
> - I will submit patches to follow the same approach in all other WUI cgi pages once this
>     has been submitted into next
> - bgcolor was deprecated in HTML 4.01 and is not supported by HTML 5
> - The orange colour for IP's that are outside the IPFire green and blue subnets does not
>     work on any browser I am using.
> - I used the CSS approach that @Leo used in the Zone Configuration cgi page
> - This patch changes all existing bgcolor entries to the css based background-color
> - Tested on my vm testbed and confirmed to work. The Orange colour for IP's outside of
>     the subnet now shows up.
> 
> Fixes: Bug#10629
> Tested-by: Adolf Belka <adolf.belka@ipfire.org>
> Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
> ---
>   config/cfgroot/header.pl | 17 +++++++++++++++++
>   html/cgi-bin/dhcp.cgi    | 23 ++++++++++++-----------
>   2 files changed, 29 insertions(+), 11 deletions(-)
> 
> diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl
> index 3956d80a1..b25f83e26 100644
> --- a/config/cfgroot/header.pl
> +++ b/config/cfgroot/header.pl
> @@ -41,6 +41,23 @@ $Header::colourvpn = '#990099';
>   $Header::colourerr = '#FF0000';
>   $Header::viewsize = 150;
>   $Header::errormessage = '';
> +$Header::extraHead = <<END
> +<style>
> +	.row-color20 {
> +		background-color: $color{'color20'};
> +	}
> +	.row-color22 {
> +		background-color: $color{'color22'};
> +	}
> +	.row-colouryellow {
> +		background-color: $Header::colouryellow;
> +	}
> +	.cell-orange {
> +		background-color: orange;
> +	}			
> +</style>
> +END
> +;
>   my %menuhash = ();
>   my $menu = \%menuhash;
>   %settings = ();
> diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi
> index 125713285..4d4c21a7f 100644
> --- a/html/cgi-bin/dhcp.cgi
> +++ b/html/cgi-bin/dhcp.cgi
> @@ -547,7 +547,8 @@ if ($dhcpsettings{'ACTION'} eq '' ) { # First launch from GUI
>       $dhcpsettings{'ADVOPT_ENABLED'} = 'on';
>       }
>   
> -&Header::openpage($Lang::tr{'dhcp configuration'}, 1, '');
> +### START PAGE ###
> +&Header::openpage($Lang::tr{'dhcp configuration'}, 1, $Header::extraHead);
>   &Header::openbigbox('100%', 'left', '', $errormessage);
>   
>   if ($errormessage) {
> @@ -843,11 +844,11 @@ foreach my $line (@current1) {
>       }
>   
>       if ($dhcpsettings{'KEY1'} eq $key) {
> -	print "<tr bgcolor='${Header::colouryellow}'>";
> +	print "<tr class='row-colouryellow'>";
>       } elsif ($key % 2) {
> -	print "<tr bgcolor='$color{'color22'}'>";
> +	print "<tr class='row-color22'>";
>       } else {
> -	print "<tr bgcolor='$color{'color20'}'>";
> +	print "<tr class='row-color20'>";
>       }
>   
>       print <<END
> @@ -1069,13 +1070,13 @@ foreach my $line (@current2) {
>   
>       if ($dhcpsettings{'KEY2'} eq $key) {
>   	print "<tr>";
> -	$col="bgcolor='${Header::colouryellow}'";
> +	$col="class='row-colouryellow'";
>       } elsif ($key % 2) {
>   	print "<tr>";
> -	$col="bgcolor='$color{'color20'}'";
> +	$col="class='row-color20'";
>       } else {
>   	print "<tr>";
> -	$col="bgcolor='$color{'color22'}'";
> +	$col="class='row-color22'";
>       }
>       my $TAG0 = '';
>       my $TAG1 = '';
> @@ -1091,12 +1092,12 @@ foreach my $line (@current2) {
>   	$TAG3 = '</b>';
>       }
>       if ($ipoutside{$temp[1]} > 0) {
> -	$TAG4 = "bgcolor='orange'" if ($dhcpsettings{'KEY2'} ne $key);
> +	$TAG4 = "class='cell-orange'" if ($dhcpsettings{'KEY2'} ne $key);
>       }
>   
>       print <<END
>   <td align='center' $col>$TAG2$temp[0]$TAG3</td>
> -<td align='center' $col $TAG4>$TAG0$temp[1]$TAG1</td>
> +<td align='center' $TAG4 $col>$TAG0$temp[1]$TAG1</td>
>   <td align='center' $col>$temp[6]&nbsp;</td>
>   <td align='center' $col>$temp[3]&nbsp;</td>
>   <td align='center' $col>$temp[4]&nbsp;</td>
> @@ -1153,8 +1154,8 @@ print <<END
>   </tr>
>   <tr>
>   	<td>&nbsp;</td>
> -	<td bgcolor='orange'>&nbsp;</td>
> -	<td class='base'>$Lang::tr{'ip address outside subnets'}</td>
> +	<td>&nbsp;</td>
> +	<td class='base cell-orange'>$Lang::tr{'ip address outside subnets'}</td>
>   	<td>&nbsp;</td>
>   	<td>&nbsp;</td>
>   	$dup
  

Patch

diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl
index 3956d80a1..b25f83e26 100644
--- a/config/cfgroot/header.pl
+++ b/config/cfgroot/header.pl
@@ -41,6 +41,23 @@  $Header::colourvpn = '#990099';
 $Header::colourerr = '#FF0000';
 $Header::viewsize = 150;
 $Header::errormessage = '';
+$Header::extraHead = <<END
+<style>
+	.row-color20 {
+		background-color: $color{'color20'};
+	}
+	.row-color22 {
+		background-color: $color{'color22'};
+	}
+	.row-colouryellow {
+		background-color: $Header::colouryellow;
+	}
+	.cell-orange {
+		background-color: orange;
+	}			
+</style>
+END
+;
 my %menuhash = ();
 my $menu = \%menuhash;
 %settings = ();
diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi
index 125713285..4d4c21a7f 100644
--- a/html/cgi-bin/dhcp.cgi
+++ b/html/cgi-bin/dhcp.cgi
@@ -547,7 +547,8 @@  if ($dhcpsettings{'ACTION'} eq '' ) { # First launch from GUI
     $dhcpsettings{'ADVOPT_ENABLED'} = 'on';
     }
 
-&Header::openpage($Lang::tr{'dhcp configuration'}, 1, '');
+### START PAGE ###
+&Header::openpage($Lang::tr{'dhcp configuration'}, 1, $Header::extraHead);
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
 if ($errormessage) {
@@ -843,11 +844,11 @@  foreach my $line (@current1) {
     }
 
     if ($dhcpsettings{'KEY1'} eq $key) {
-	print "<tr bgcolor='${Header::colouryellow}'>";
+	print "<tr class='row-colouryellow'>";
     } elsif ($key % 2) {
-	print "<tr bgcolor='$color{'color22'}'>";
+	print "<tr class='row-color22'>";
     } else {
-	print "<tr bgcolor='$color{'color20'}'>";
+	print "<tr class='row-color20'>";
     }
 
     print <<END
@@ -1069,13 +1070,13 @@  foreach my $line (@current2) {
 
     if ($dhcpsettings{'KEY2'} eq $key) {
 	print "<tr>";
-	$col="bgcolor='${Header::colouryellow}'";
+	$col="class='row-colouryellow'";
     } elsif ($key % 2) {
 	print "<tr>";
-	$col="bgcolor='$color{'color20'}'";
+	$col="class='row-color20'";
     } else {
 	print "<tr>";
-	$col="bgcolor='$color{'color22'}'";
+	$col="class='row-color22'";
     }
     my $TAG0 = '';
     my $TAG1 = '';
@@ -1091,12 +1092,12 @@  foreach my $line (@current2) {
 	$TAG3 = '</b>';
     }
     if ($ipoutside{$temp[1]} > 0) {
-	$TAG4 = "bgcolor='orange'" if ($dhcpsettings{'KEY2'} ne $key);
+	$TAG4 = "class='cell-orange'" if ($dhcpsettings{'KEY2'} ne $key);
     }
 
     print <<END
 <td align='center' $col>$TAG2$temp[0]$TAG3</td>
-<td align='center' $col $TAG4>$TAG0$temp[1]$TAG1</td>
+<td align='center' $TAG4 $col>$TAG0$temp[1]$TAG1</td>
 <td align='center' $col>$temp[6]&nbsp;</td>
 <td align='center' $col>$temp[3]&nbsp;</td>
 <td align='center' $col>$temp[4]&nbsp;</td>
@@ -1153,8 +1154,8 @@  print <<END
 </tr>
 <tr>
 	<td>&nbsp;</td>
-	<td bgcolor='orange'>&nbsp;</td>
-	<td class='base'>$Lang::tr{'ip address outside subnets'}</td>
+	<td>&nbsp;</td>
+	<td class='base cell-orange'>$Lang::tr{'ip address outside subnets'}</td>
 	<td>&nbsp;</td>
 	<td>&nbsp;</td>
 	$dup