ddns.cgi: Fix coding style.

This commit is contained in:
Michael Tremer
2014-08-07 20:40:14 +02:00
parent 458064c519
commit c330d115bf

View File

@@ -89,7 +89,6 @@ close (FILE);
# Save General Settings.
#
if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
# Open /var/ipfire/ddns/settings for writing.
open(FILE, ">$settingsfile") or die "Unable to open $settingsfile.";
@@ -115,7 +114,6 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
# Toggle enable/disable field. Field is in second position
#
if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
# Open /var/ipfire/ddns/config for writing.
open(FILE, ">$datafile") or die "Unable to open $datafile.";
@@ -127,23 +125,19 @@ if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
# Read file line by line.
foreach my $line (@current) {
# Remove newlines.
chomp($line);
if ($settings{'ID'} eq $id) {
# Splitt lines (splitting element is a single ",") and save values into temp array.
@temp = split(/\,/,$line);
# Check if we want to toggle ENABLED or WILDCARDS.
if ($settings{'ENABLED'} ne '') {
# Update ENABLED.
print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$settings{'ENABLED'}\n";
}
} else {
# Print unmodified line.
print FILE "$line\n";
}
@@ -155,9 +149,6 @@ if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
# Close file after writing.
close(FILE);
# Unset given CGI params.
undef %settings;
# Write out logging notice.
&General::log($Lang::tr{'ddns hostname modified'});
@@ -192,8 +183,7 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
}
# Go furter if there was no error.
if ( ! $errormessage) {
if (!$errormessage) {
# Splitt hostname field into 2 parts for storrage.
my($hostname, $domain) = split(/\./, $settings{'HOSTNAME'}, 2);
@@ -205,7 +195,6 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
# Handle adding new accounts.
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Open /var/ipfire/ddns/config for writing.
open(FILE, ">>$datafile") or die "Unable to open $datafile.";
@@ -223,7 +212,6 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
# Handle account edditing.
} elsif ($settings{'ACTION'} eq $Lang::tr{'update'}) {
# Open /var/ipfire/ddns/config for writing.
open(FILE, ">$datafile") or die "Unable to open $datafile.";
@@ -234,7 +222,6 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
# Read file line by line.
foreach my $line (@current) {
if ($settings{'ID'} eq $id) {
print FILE "$settings{'SERVICE'},$hostname,$domain,$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n";
} else {
@@ -264,7 +251,6 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
# Remove existing accounts.
#
if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
# Open /var/ipfire/ddns/config for writing.
open(FILE, ">$datafile") or die "Unable to open $datafile.";
@@ -275,7 +261,6 @@ if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
# Read file line by line.
foreach my $line (@current) {
# Write back every line, except the one we want to drop
# (identified by the ID)
unless ($settings{'ID'} eq $id) {
@@ -303,15 +288,12 @@ if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
# Read items for editing.
#
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
my $id = 0;
my @temp;
# Read file line by line.
foreach my $line (@current) {
if ($settings{'ID'} eq $id) {
# Remove newlines.
chomp($line);
@@ -326,10 +308,12 @@ if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
$settings{'PASSWORD'} = $temp[6];
$settings{'ENABLED'} = $temp[7];
}
# Increase $id.
$id++;
# Increase $id.
$id++;
}
&GenerateDDNSConfigFile();
}
#
@@ -410,18 +394,15 @@ my $buttontext = $Lang::tr{'add'};
# Change buttontext and headline if we edit an account.
if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
# Rename button and print headline for updating.
$buttontext = $Lang::tr{'update'};
&Header::openbox('100%', 'left', $Lang::tr{'edit an existing host'});
} else {
# Otherwise use default button text and show headline for adding a new account.
&Header::openbox('100%', 'left', $Lang::tr{'add a host'});
}
print <<END
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ID' value='$settings{'ID'}' />
<table width='100%'>
@@ -437,7 +418,6 @@ END
# Loop to print the providerlist.
foreach my $provider (@providers) {
# Check if the current provider needs to be selected.
if ($provider eq $settings{'SERVICE'}) {
$selected = 'selected';