From: Franck B. <fra...@us...> - 2007-06-26 22:40:55
|
Update of /cvsroot/ipcop/ipcop/html/cgi-bin In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv6514/html/cgi-bin Modified Files: Tag: IPCOP_v1_4_0 dhcp.cgi Log Message: Changed some perl syntax (split,join) to avoid warnings in the fixed_leases portion of the dhcp.cgi code. Index: dhcp.cgi =================================================================== RCS file: /cvsroot/ipcop/ipcop/html/cgi-bin/dhcp.cgi,v retrieving revision 1.14.2.97 retrieving revision 1.14.2.98 diff -C2 -d -r1.14.2.97 -r1.14.2.98 *** dhcp.cgi 8 Mar 2007 09:43:28 -0000 1.14.2.97 --- dhcp.cgi 26 Jun 2007 22:40:53 -0000 1.14.2.98 *************** *** 99,103 **** $dhcpsettings{'ADVOPT_NAME'} = ''; $dhcpsettings{'ADVOPT_DATA'} = ''; ! unshift (@nosaved,'ADVOPT_ENABLED','ADVOPT_NAME','ADVOPT_DATA'); foreach my $itf (@ITFs) { $dhcpsettings{"ADVOPT_SCOPE_${itf}"} = 'off'; --- 99,105 ---- $dhcpsettings{'ADVOPT_NAME'} = ''; $dhcpsettings{'ADVOPT_DATA'} = ''; ! $dhcpsettings{'SUBMIT'} = ''; ! $dhcpsettings{'ACTION_ALL'} = ''; ! unshift (@nosaved,'ADVOPT_ENABLED','ADVOPT_NAME','ADVOPT_DATA','SUBMIT','ACTION_ALL'); foreach my $itf (@ITFs) { $dhcpsettings{"ADVOPT_SCOPE_${itf}"} = 'off'; *************** *** 403,409 **** #move out new line chomp(@current2[$dhcpsettings{'KEY2'}]); ! my @temp = split(/\,/,@current2[$dhcpsettings{'KEY2'}]); ! $temp[2] = $temp[2] eq 'on' ? '' : 'on'; # Toggle the field ! @current2[$dhcpsettings{'KEY2'}] = join (',',@temp)."\n"; $dhcpsettings{'KEY2'} = ''; # End edit mode &General::log($Lang::tr{'fixed ip lease modified'}); --- 405,411 ---- #move out new line chomp(@current2[$dhcpsettings{'KEY2'}]); ! my ($FIX_MAC,$FIX_ADDR,$FIX_ENABLED,$DATA) = split(',', @current2[$dhcpsettings{'KEY2'}],4); ! $FIX_ENABLED = $FIX_ENABLED eq 'on' ? '' : 'on'; # Toggle the field ! @current2[$dhcpsettings{'KEY2'}] = "$FIX_MAC,$FIX_ADDR,$FIX_ENABLED,$DATA\n"; $dhcpsettings{'KEY2'} = ''; # End edit mode &General::log($Lang::tr{'fixed ip lease modified'}); *************** *** 411,415 **** print FILE @current2; close(FILE); ! #Write changes to dhcpd.conf. &buildconf; --- 413,417 ---- print FILE @current2; close(FILE); ! #Write changes to dhcpd.conf. &buildconf; *************** *** 434,438 **** CHECK:foreach my $line (@current2) { ! my @temp = split(/\,/,$line); if($dhcpsettings{'KEY2'} ne $key) { # same MAC is OK on different subnets. This test is not complete because --- 436,440 ---- CHECK:foreach my $line (@current2) { ! my @temp = split(',', $line); if($dhcpsettings{'KEY2'} ne $key) { # same MAC is OK on different subnets. This test is not complete because *************** *** 540,559 **** } } - if ($dhcpsettings{'ACTION'} eq $Lang::tr{'edit'}.'2') { #move out new line my $line = @current2[$dhcpsettings{'KEY2'}]; chomp($line); ! my @temp = split(/\,/, $line); ! $dhcpsettings{'FIX_MAC'}=$temp[0]; ! $dhcpsettings{'FIX_ADDR'}=$temp[1]; ! $dhcpsettings{'FIX_ENABLED'}=$temp[2]; ! $dhcpsettings{'FIX_NEXTADDR'}=$temp[3]; ! $dhcpsettings{'FIX_FILENAME'}=$temp[4]; ! $dhcpsettings{'FIX_ROOTPATH'}=$temp[5]; ! $dhcpsettings{'FIX_REMARK'}=$temp[6]; ! $dhcpsettings{'FIX_HOSTNAME'}=$temp[7]; ! $dhcpsettings{'FIX_ROUTER'}=$temp[8]; ! $dhcpsettings{'FIX_DNS'}=$temp[9]; } --- 542,559 ---- } } if ($dhcpsettings{'ACTION'} eq $Lang::tr{'edit'}.'2') { #move out new line my $line = @current2[$dhcpsettings{'KEY2'}]; chomp($line); ! ($dhcpsettings{'FIX_MAC'}, ! $dhcpsettings{'FIX_ADDR'}, ! $dhcpsettings{'FIX_ENABLED'}, ! $dhcpsettings{'FIX_NEXTADDR'}, ! $dhcpsettings{'FIX_FILENAME'}, ! $dhcpsettings{'FIX_ROOTPATH'}, ! $dhcpsettings{'FIX_REMARK'}, ! $dhcpsettings{'FIX_HOSTNAME'}, ! $dhcpsettings{'FIX_ROUTER'}, ! $dhcpsettings{'FIX_DNS'})=split(',', $line); } *************** *** 934,938 **** <td class='base'>$Lang::tr{'dns server'}: <img src='/blob.gif' alt='*' /></td> <td><input type='text' name='FIX_DNS' value='$dhcpsettings{'FIX_DNS'}' size='18' /></td> ! </tr><tr> --- 934,940 ---- <td class='base'>$Lang::tr{'dns server'}: <img src='/blob.gif' alt='*' /></td> <td><input type='text' name='FIX_DNS' value='$dhcpsettings{'FIX_DNS'}' size='18' /></td> ! END ! ; ! print <<END </tr><tr> *************** *** 999,1018 **** # mark duplicate ip or duplicate MAC foreach my $line (@current2) { ! my @temp = split(/\,/,$line); ! $macdupl{$temp[0]} += 1; ! if ($macdupl{$temp[0]} > 1) { $ipdup = 1; # Flag up duplicates for use later } ! $ipinuse{$temp[1]} += 1; ! if ($ipinuse{$temp[1]} > 1) { $ipdup = 1; # Flag up duplicates for use later } # Mark IP addresses outwith known subnets ! $ipoutside{$temp[1]} = 1; foreach my $itf (@ITFs) { ! if ( &General::IpInSubnet($temp[1], $netsettings{"${itf}_NETADDRESS"}, $netsettings{"${itf}_NETMASK"})) { ! $ipoutside{$temp[1]} = 0; } } --- 1001,1020 ---- # mark duplicate ip or duplicate MAC foreach my $line (@current2) { ! my ($FIX_MAC, $FIX_ADDR) = split(',', $line); ! $macdupl{$FIX_MAC} += 1; ! if ($macdupl{$FIX_MAC} > 1) { $ipdup = 1; # Flag up duplicates for use later } ! $ipinuse{$FIX_ADDR} += 1; ! if ($ipinuse{$FIX_ADDR} > 1) { $ipdup = 1; # Flag up duplicates for use later } # Mark IP addresses outwith known subnets ! $ipoutside{$FIX_ADDR} = 1; foreach my $itf (@ITFs) { ! if ( &General::IpInSubnet($FIX_ADDR, $netsettings{"${itf}_NETADDRESS"}, $netsettings{"${itf}_NETMASK"})) { ! $ipoutside{$FIX_ADDR} = 0; } } *************** *** 1024,1030 **** my $gdesc = ''; chomp($line); # remove newline ! my @temp = split(/\,/,$line); ! if ($temp[2] eq "on") { $gif = 'on.gif'; $gdesc = $Lang::tr{'click to disable'}; --- 1026,1041 ---- my $gdesc = ''; chomp($line); # remove newline ! my ($FIX_MAC, ! $FIX_ADDR, ! $FIX_ENABLED, ! $FIX_NEXTADDR, ! $FIX_FILENAME, ! $FIX_ROOTPATH, ! $FIX_REMARK, ! $FIX_HOSTNAME, ! $FIX_ROUTER, ! $FIX_DNS) = split(',', $line); ! if ($FIX_ENABLED eq "on") { $gif = 'on.gif'; $gdesc = $Lang::tr{'click to disable'}; *************** *** 1039,1043 **** print "<tr bgcolor='${Header::table2colour}'>"; } else { ! print "<tr bgcolor='${Header::table1colour}'>"; } my $TAG0 = ''; --- 1050,1054 ---- print "<tr bgcolor='${Header::table2colour}'>"; } else { ! print "<tr bgcolor='${Header::table1colour}'>"; } my $TAG0 = ''; *************** *** 1046,1072 **** my $TAG3 = ''; my $TAG4 = ''; ! if ($ipinuse{$temp[1]} > 1) { $TAG0 = '<b>'; $TAG1 = '</b>'; } ! if (($macdupl{$temp[0]} > 1) || ( grep (/$temp[0]/, $newmacs) ) ) { $TAG2 = '<b>'; $TAG3 = '</b>'; } ! if ($ipoutside{$temp[1]} > 0) { $TAG4 = "bgcolor='orange'" if ($dhcpsettings{'KEY2'} ne $key); } ! # uncode commas ! $temp[4] =~ s/,/,/g; ! $temp[5] =~ s/,/,/g; print <<END ! <td align='center'>$TAG2$temp[0]$TAG3</td> ! <td align='center' $TAG4>$TAG0$temp[1]$TAG1</td> ! <td align='center'>$temp[7] </td> ! <td align='center'>$temp[6] </td> ! <td align='center'>$temp[3] </td> ! <td align='center'>$temp[4] </td> ! <td align='center'>$temp[5] </td> <td align='center'> --- 1057,1083 ---- my $TAG3 = ''; my $TAG4 = ''; ! if ($ipinuse{$FIX_ADDR} > 1) { $TAG0 = '<b>'; $TAG1 = '</b>'; } ! if (($macdupl{$FIX_MAC} > 1) || ( grep (/$FIX_MAC/, $newmacs) ) ) { $TAG2 = '<b>'; $TAG3 = '</b>'; } ! if ($ipoutside{$FIX_ADDR} > 0) { $TAG4 = "bgcolor='orange'" if ($dhcpsettings{'KEY2'} ne $key); } ! # uncode commas if field is not empty ! $FIX_FILENAME =~ s/,/,/g; ! $FIX_ROOTPATH =~ s/,/,/g; print <<END ! <td align='center'>$TAG2$FIX_MAC$TAG3</td> ! <td align='center' $TAG4>$TAG0$FIX_ADDR$TAG1</td> ! <td align='center'>$FIX_HOSTNAME </td> ! <td align='center'>$FIX_REMARK </td> ! <td align='center'>$FIX_NEXTADDR </td> ! <td align='center'>$FIX_FILENAME </td> ! <td align='center'>$FIX_ROOTPATH </td> <td align='center'> *************** *** 1192,1197 **** foreach my $line (@current2) { chomp( $line); #remove newline because can be on field 5 or 6 (addition of REMARK) ! my @temp = split (',',$line); ! my @record = ('FETHER',$temp[0],'FIPADDR',$temp[1],'DATA',join(',',@temp[2..9])); my $record = {}; # create a reference to empty hash %{$record} = @record; # populate that hash with @record --- 1203,1208 ---- foreach my $line (@current2) { chomp( $line); #remove newline because can be on field 5 or 6 (addition of REMARK) ! my ($FIX_MAC, $FIX_ADDR, $DATA) = split(',', $line,3); ! my @record = ('FETHER',$FIX_MAC,'FIPADDR',$FIX_ADDR,'DATA',$DATA); my $record = {}; # create a reference to empty hash %{$record} = @record; # populate that hash with @record *************** *** 1199,1203 **** $entries{$record->{FETHER} . $record->{FIPADDR}} = $record; # add this to a hash of hashes } ! open(FILE, ">$filename2") or die 'Unable to open fixed lease file.'; foreach my $entry ( sort fixedleasesort keys %entries) { --- 1210,1214 ---- $entries{$record->{FETHER} . $record->{FIPADDR}} = $record; # add this to a hash of hashes } ! open(FILE, ">$filename2") or die 'Unable to open fixed lease file.'; foreach my $entry ( sort fixedleasesort keys %entries) { *************** *** 1307,1328 **** foreach my $line (@current2) { chomp($line); ! my @temp = split(/\,/,$line); ! if ($temp[2] eq "on") { ! print FILE "\nhost " . ($temp[7] ? $temp[7]: "fix$key") . " # $temp[6]\n"; print FILE "{\n"; ! print FILE "\thardware ethernet $temp[0];\n" if ($temp[0]); ! print FILE "\tfixed-address $temp[1];\n"; ! print FILE "\tnext-server $temp[3];\n" if ($temp[3]); ! $temp[4] =~ s/,/,/g; ! print FILE "\tfilename \"$temp[4]\";\n" if ($temp[4]); ! $temp[5] =~ s/,/,/g; ! print FILE "\toption root-path \"$temp[5]\";\n" if ($temp[5]); ! if ($temp[7]) { ! my @v = split (/\./, $temp[7], 2); ! print FILE "\toption host-name \"$v[0]\";\n" ; ! print FILE "\toption domain-name \"$v[1]\";\n" if ($v[1]); } ! print FILE "\toption routers $temp[8];\n" if ($temp[8]); ! print FILE "\toption domain-name-servers $temp[9];\n" if ($temp[9]); print FILE "}\n"; $key++; --- 1318,1349 ---- foreach my $line (@current2) { chomp($line); ! my ($FIX_MAC, ! $FIX_ADDR, ! $FIX_ENABLED, ! $FIX_NEXTADDR, ! $FIX_FILENAME, ! $FIX_ROOTPATH, ! $FIX_REMARK, ! $FIX_HOSTNAME, ! $FIX_ROUTER, ! $FIX_DNS) = split(',', $line); ! ! if ($FIX_ENABLED eq "on") { ! print FILE "\nhost " . ($FIX_HOSTNAME ? $FIX_HOSTNAME: "fix$key") . " # $FIX_REMARK\n"; print FILE "{\n"; ! print FILE "\thardware ethernet $FIX_MAC;\n" if ($FIX_MAC); ! print FILE "\tfixed-address $FIX_ADDR;\n"; ! print FILE "\tnext-server $FIX_NEXTADDR;\n" if ($FIX_NEXTADDR); ! $FIX_FILENAME =~ s/,/,/g; ! print FILE "\tfilename \"$FIX_FILENAME\";\n" if ($FIX_FILENAME); ! $FIX_ROOTPATH =~ s/,/,/g; ! print FILE "\toption root-path \"$FIX_ROOTPATH\";\n" if ($FIX_ROOTPATH); ! if ($FIX_HOSTNAME) { ! my ($opt_host, $opt_dom) = split (/\./, $FIX_HOSTNAME, 2); ! print FILE "\toption host-name \"$opt_host\";\n" ; ! print FILE "\toption domain-name \"$opt_dom\";\n" if ($opt_dom); } ! print FILE "\toption routers $FIX_ROUTER;\n" if ($FIX_ROUTER); ! print FILE "\toption domain-name-servers $FIX_DNS;\n" if ($FIX_DNS); print FILE "}\n"; $key++; *************** *** 1429,1433 **** for ($i=0; $i<@ret; $i++) { #look for the error condition ! if ( @ret[$i] =~ /^Configuration file errors encountered/ ) { return "<pre>$ret[$i-3]$ret[$i-2]$ret[$i-1]</pre>"; --- 1450,1454 ---- for ($i=0; $i<@ret; $i++) { #look for the error condition ! if ( $ret[$i] =~ /^Configuration file errors encountered/ ) { return "<pre>$ret[$i-3]$ret[$i-2]$ret[$i-1]</pre>"; |