From: Stefan Schantl Date: Tue, 5 Aug 2014 19:24:44 +0000 (+0200) Subject: ddns.cgi: Fix enable/disable handling of entries. X-Git-Tag: v2.15-core81~6^2 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=c2f80e67a711eee43dd5c815defc689fc7604b64;ds=sidebyside ddns.cgi: Fix enable/disable handling of entries. When the "enabled" checkbox is checked a "on" will be returned, if the box is unchecked checkboxes will return nothing. As a result of this behaviour the ddns.conf contained entries which have been disabled in the WUI. We now check if the checkbox returns a "on", otherwise we will set the "enabled" value to "off" to prevent from this problem. --- diff --git a/html/cgi-bin/ddns.cgi b/html/cgi-bin/ddns.cgi index 65e3bee395..dc5dacc247 100644 --- a/html/cgi-bin/ddns.cgi +++ b/html/cgi-bin/ddns.cgi @@ -197,6 +197,12 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang:: # Splitt hostname field into 2 parts for storrage. my($hostname, $domain) = split(/\./, $settings{'HOSTNAME'}, 2); + # Handle enabled checkbox. When the checkbox is selected a "on" will be returned, + # if the checkbox is not checked nothing is returned in this case we set the value to "off". + if ($settings{'ENABLED'} ne 'on') { + $settings{'ENABLED'} = 'off'; + } + # Handle adding new accounts. if ($settings{'ACTION'} eq $Lang::tr{'add'}) { @@ -215,8 +221,6 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang:: # Write out notice to logfile. &General::log($Lang::tr{'ddns hostname added'}); - # Update ddns config file. - # Handle account edditing. } elsif ($settings{'ACTION'} eq $Lang::tr{'update'}) { @@ -354,7 +358,9 @@ $checked{'BEHINDROUTER'}{'RED_IP'} = ''; $checked{'BEHINDROUTER'}{'FETCH_IP'} = ''; $checked{'BEHINDROUTER'}{$settings{'BEHINDROUTER'}} = "checked='checked'"; -$checked{'ENABLED'}{'on'} = ($settings{'ENABLED'} eq '' ) ? '' : "checked='checked'"; +$checked{'ENABLED'}{'on'} = ''; +$checked{'ENABLED'}{'off'} = ''; +$checked{'ENABLED'}{$settings{'ENABLED'}} = "checked='checked'"; # Show box for errormessages.. if ($errormessage) { @@ -451,7 +457,7 @@ print < $Lang::tr{'enabled'} - + $Lang::tr{'username'}