[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipcop-svn
Subject:    [Ipcop-svn] SF.net SVN: ipcop: [424]
From:       gespinasse () users ! sourceforge ! net
Date:       2007-06-30 6:42:44
Message-ID: E1I4WfM-0006O9-MV () sc8-pr-svn4 ! sourceforge ! net
[Download RAW message or body]

Revision: 424
          http://ipcop.svn.sourceforge.net/ipcop/?rev=424&view=rev
Author:   gespinasse
Date:     2007-06-29 23:42:44 -0700 (Fri, 29 Jun 2007)

Log Message:
-----------
Fix some warnings and not so consistent behavior in xtaccess page

PROTOCOL and DEST are only preset to default value when no action is
required.
So when you display the page the first time, PROTOCOL is preset to TCP.
But when you remove one line already registered, ACTION is not empty and
PROTOCOL appear preset to UDP.
Preset DEST and PROTOCOL to default values at the beginning of the page to
fix warnings 'Use of uninitialized value in concatenation' during 'remove' action.

I don't find a reason to undef %cgihash on 'add' action.
It just add more warnings because ACTION is no more defined.

$selected{} was not properly constructed with aliases adresses.
This produce this sort of warning on log when run with warning enabled:
Use of uninitialized value in concatenation (.) or string at
/home/httpd/cgi-bin/xtaccess.cgi line 207, <ALIASES> line 1.

Usage of ',' should be more clear than  /\,/ with split

Replace @dummy workaround with use warnings; no warnings 'once';

Modified Paths:
--------------
    ipcop/trunk/html/cgi-bin/xtaccess.cgi

Modified: ipcop/trunk/html/cgi-bin/xtaccess.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/xtaccess.cgi	2007-06-27 05:44:21 UTC (rev 423)
+++ ipcop/trunk/html/cgi-bin/xtaccess.cgi	2007-06-30 06:42:44 UTC (rev 424)
@@ -13,17 +13,13 @@
 use strict;
 
 # enable only the following on debugging purpose
-#use warnings;
+#use warnings; no warnings 'once';# 'redefine', 'uninitialized';
 #use CGI::Carp 'fatalsToBrowser';
 
 require 'CONFIG_ROOT/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
-#workaround to suppress a warning when a variable is used only once
-my @dummy = ( ${Header::colouryellow} );
-undef (@dummy);
-
 my %cgiparams=();
 my %checked=();
 my %selected=();
@@ -39,6 +35,8 @@
 $cgiparams{'SRC'} = '';
 $cgiparams{'DEST_PORT'} = '';
 $cgiparams{'REMARK'} ='';
+$cgiparams{'PROTOCOL'} = 'tcp';
+$cgiparams{'DEST'} = '0.0.0.0';
 &Header::getcgihash(\%cgiparams);
 open(FILE, $filename) or die 'Unable to open config file.';
 my @current = <FILE>;
@@ -76,7 +74,6 @@
 			}
 		}
 		close(FILE);
-		undef %cgiparams;
 		$changed = 'yes';
 		&General::log($Lang::tr{'external access rule added'});
 		system('/usr/local/bin/setxtaccess');
@@ -115,7 +112,7 @@
 		else
 		{
 			chomp($line);
-			my @temp = split(/\,/,$line);
+			my @temp = split(',',$line);
 			print FILE "$temp[0],$temp[1],$temp[2],$cgiparams{'ENABLE'},$temp[4],$temp[5]\n";
 		}
 	}
@@ -131,7 +128,7 @@
 		if ($cgiparams{'ID'} eq $id)
 		{
 			chomp($line);
-			my @temp = split(/\,/,$line);
+			my @temp = split(',',$line);
 			$cgiparams{'PROTOCOL'} = $temp[0];
 			$cgiparams{'SRC'} = $temp[1];
 			$cgiparams{'DEST_PORT'} = $temp[2];
@@ -141,18 +138,23 @@
 		}
 	}
 }
+# 'off' value on checkbox does not exist on cgi hash,
+# so can't be initialized to 'on' before reading the hash or you can't unselect the \
box. +# Set only to 'on' each time the page is displayed with no action
+if ($cgiparams{'ACTION'} eq '') { $cgiparams{'ENABLED'} = 'on'; }
 
-if ($cgiparams{'ACTION'} eq '')
-{
-	$cgiparams{'PROTOCOL'} = 'tcp';
-	$cgiparams{'DEST'} = '0.0.0.0';
-	$cgiparams{'ENABLED'} = 'on';
-}
-
 $selected{'PROTOCOL'}{'udp'} = '';
 $selected{'PROTOCOL'}{'tcp'} = '';
 $selected{'PROTOCOL'}{$cgiparams{'PROTOCOL'}} = "selected='selected'";
 
+$selected{'DEST'}{'0.0.0.0'} ='';
+open(ALIASES, "$aliasfile") or die 'Unable to open aliases file.';
+while (<ALIASES>) {
+	chomp($_);
+	my @temp = split(',',$_);
+	if ($temp[1] eq 'on') { $selected{'DEST'}{$temp[0]} =''; }
+}
+close(ALIASES);
 $selected{'DEST'}{$cgiparams{'DEST'}} = "selected='selected'";
 
 $checked{'ENABLED'}{'off'} = '';
@@ -207,7 +209,7 @@
 while (<ALIASES>)
 {
 	chomp($_);
-	my @temp = split(/\,/,$_);
+	my @temp = split(',',$_);
 	if ($temp[1] eq 'on') {
 		print "<option value='$temp[0]' $selected{'DEST'}{$temp[0]}>$temp[0]";
 		if (defined $temp[2] and ($temp[2] ne '')) { print " ($temp[2])"; }
@@ -277,7 +279,7 @@
 {
 	$id++;
 	chomp($line);
-	my @temp = split(/\,/,$line);
+	my @temp = split(',',$line);
 	my $protocol = '';
 	my $gif = '';
 	my $gdesc = '';


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic