# 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.";
# 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.";
# 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";
}
# Close file after writing.
close(FILE);
- # Unset given CGI params.
- undef %settings;
-
# Write out logging notice.
&General::log($Lang::tr{'ddns hostname modified'});
}
# 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);
# 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.";
# 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.";
# 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 {
# 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.";
# 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) {
# 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);
$settings{'PASSWORD'} = $temp[6];
$settings{'ENABLED'} = $temp[7];
}
- # Increase $id.
- $id++;
+ # Increase $id.
+ $id++;
}
+
+ &GenerateDDNSConfigFile();
}
#
# 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%'>
# 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';