From: eldy <> Date: Tue, 16 Sep 2003 15:24:38 +0000 (+0000) Subject: Fix minor bugs X-Git-Tag: AWSTATS_WEBMIN_1_1_BETA~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95a6c1c3fc0686836cc3374bebba8aaccc527bb1;p=thirdparty%2FAWStats.git Fix minor bugs --- diff --git a/tools/webmin/awstats/awstats-lib.pl b/tools/webmin/awstats/awstats-lib.pl index d83cdffb..f0f1fd13 100644 --- a/tools/webmin/awstats/awstats-lib.pl +++ b/tools/webmin/awstats/awstats-lib.pl @@ -33,14 +33,18 @@ if (! $file) { error("Call to update_config with wrong parameter"); } open(FILE, $file) || error("Failed to open $file for update"); open(FILETMP, ">$file.tmp") || error("Failed to open $file.tmp for writing"); -local $conflinenb = 0; +# $%conf contains param and values +my %confchanged=(); +my $conflinenb = 0; + +# First, change values that are already present in old config file while() { my $savline=$_; chomp $_; s/\r//; $conflinenb++; - # Remove comments + # Remove comments not at beginning of line $_ =~ s/\s#.*$//; # Extract param and value @@ -48,15 +52,26 @@ while() { $param =~ s/^\s+//; $param =~ s/\s+$//; if ($param) { - if ($conf->{$param}) { + # cleanparam is param without begining # + my $cleanparam=$param; $cleanparam =~ s/^#//; + if (defined($conf->{$cleanparam})) { # Change line with new value - $savline = "$param=\"".($conf->{$param})."\"\n"; + $savline = "$cleanparam=\"".($conf->{$cleanparam})."\"\n"; + $confchanged{$cleanparam}=1; } } print FILETMP "$savline"; +} +# Now add values that were not present in old config file +foreach my $key (keys %$conf) { + if ($confchanged{$key}) { next; } # param already changed + print FILETMP "\n"; + print FILETMP "# Param $key added by AWStats Webmin module\n"; + print FILETMP "$key=\"$conf->{$key}\"\n"; } + close(FILE); close(FILETMP); diff --git a/tools/webmin/awstats/edit_config.cgi b/tools/webmin/awstats/edit_config.cgi index 2c3723b6..d021d934 100644 --- a/tools/webmin/awstats/edit_config.cgi +++ b/tools/webmin/awstats/edit_config.cgi @@ -38,7 +38,31 @@ foreach my $key (keys %$lconf) { print "
\n"; -print "
\n"; +print < +function Submit_onClick() { + if (document.editconfig.LogFormat.value=='') { + alert('$text{save_errLogFormat}'); + document.editconfig.LogFormat.focus(); + return false; + } + if (document.editconfig.SiteDomain.value=='') { + alert('$text{save_errSiteDomain}'); + document.editconfig.SiteDomain.focus(); + return false; + } + if (document.editconfig.DirData.value=='') { + alert('$text{save_errDirData}'); + document.editconfig.DirData.focus(); + return false; + } + return true; +} + +EOF + + +print "\n"; print "\n"; print "\n"; print "\n"; -print "\n"; print "\n"; @@ -80,11 +104,11 @@ print "\n"; print "\n"; -print "\n"; -print "\n"; -print "\n"; print "\n"; @@ -124,11 +148,11 @@ else { @b=(); if ($in{'new'}) { - push(@b, ""); + push(@b, ""); } else { if ($access{'global'}) { - push(@b, ""); + push(@b, ""); } if ($access{'add'}) { push(@b, ""); diff --git a/tools/webmin/awstats/save_config.cgi b/tools/webmin/awstats/save_config.cgi index 1b5038f1..174ee968 100644 --- a/tools/webmin/awstats/save_config.cgi +++ b/tools/webmin/awstats/save_config.cgi @@ -44,9 +44,12 @@ else { if ($key eq 'submit') { next; } if ($key eq 'oldfile') { next; } $conf{$key} = $in{$key}; - $conf{$key} =~ s/^\s*//; - $conf{$key} =~ s/\s*$//; + if ($conf{key} ne ' ') { + $conf{$key} =~ s/^\s+//; + $conf{$key} =~ s/\s+$//; + } } + if ($conf{'LogSeparator'} eq '') { $conf{'LogSeparator'}=' '; } # Check data if (! -r $conf{'LogFile'}) { &error(&text(save_errLogFile,$conf{'LogFile'})); }
"; @@ -72,7 +96,7 @@ print " "; print &hblink("Help", "help.cgi?param=LogType")."
LogFormat "; print &hblink("Help", "help.cgi?param=LogFormat"),"
LogSeparator "; +print "
LogSeparator "; print &hblink("Help", "help.cgi?param=LogSeparator")."
SiteDomain "; print &hblink("Help", "help.cgi?param=SiteDomain")."
HostAliases
DNSLookup "; print &hblink("Help", "help.cgi?param=DNSLookup")."
DirData "; +print "
DirData "; print &hblink("Help", "help.cgi?param=DirData")."
DirCgi "; +print "
DirCgi "; print &hblink("Help", "help.cgi?param=DirCgi")."
DirIcons "; +print "
DirIcons "; print &hblink("Help", "help.cgi?param=DirIcons")."
AllowToUpdateStatsFromBrowser "; print &hblink("Help", "help.cgi?param=AllowToUpdateStatsFromBrowser")."