# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2004 Craig Barratt
+# Copyright (C) 2005-2009 Craig Barratt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
#========================================================================
#
-# Version 3.0.0alpha, released 23 Jan 2006.
+# Version 3.2.0, released 31 Jul 2010.
#
# See http://backuppc.sourceforge.net.
#
use BackupPC::Config::Meta qw(:all);
use BackupPC::Storage;
use Data::Dumper;
+use Encode;
our %ConfigMenu = (
server => {
{name => "UmaskMode"},
{name => "MyPath"},
{name => "DHCPAddressRanges"},
+ {name => "CmdQueueNice"},
{name => "PerlModuleLoad"},
{name => "ServerInitdPath"},
{name => "ServerInitdStartCmd"},
{name => "Bzip2Path"},
{text => "CfgEdit_Title_Install_Paths"},
- {name => "TopDir"},
- {name => "ConfDir"},
- {name => "LogDir"},
+ #
+ # Can only edit TopDir and LogDir if we are in FHS mode.
+ # Otherwise they are hardcoded in lib/BackupPC/Lib.pm.
+ #
+ {name => "TopDir",
+ visible => sub { return $_[1]->useFHS(); } },
+ {name => "LogDir",
+ visible => sub { return $_[1]->useFHS(); } },
{name => "CgiDir"},
- {name => "InstallDir"},
+ #
+ # Cannot edit ConfDir or InstallDir, since the real value is hardcoded in
+ # lib/BackupPC/Lib.pm.
+ # {name => "ConfDir"},
+ # {name => "InstallDir"},
+ #
],
},
email => {
{name => "XferMethod", onchangeSubmit => 1},
{name => "XferLogLevel"},
{name => "ClientCharset"},
+ {name => "ClientCharsetLegacy"},
+ ### Smb Settings
{text => "CfgEdit_Title_Smb_Settings",
visible => sub { return $_[0]->{XferMethod} eq "smb"; } },
{name => "SmbShareName",
{name => "SmbSharePasswd",
visible => sub { return $_[0]->{XferMethod} eq "smb"; } },
+ ### Tar Settings
{text => "CfgEdit_Title_Tar_Settings",
visible => sub { return $_[0]->{XferMethod} eq "tar"; } },
{name => "TarShareName",
visible => sub { return $_[0]->{XferMethod} eq "tar"; } },
+ ### Rsync Settings
{text => "CfgEdit_Title_Rsync_Settings",
visible => sub { return $_[0]->{XferMethod} eq "rsync"; } },
{text => "CfgEdit_Title_Rsyncd_Settings",
visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
{name => "RsyncShareName",
visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
+ {name => "RsyncdUserName",
+ visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
{name => "RsyncdPasswd",
visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
{name => "RsyncdAuthRequired",
{name => "RsyncCsumCacheVerifyProb",
visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
+ ### Ftp Settings
+ {text => "CfgEdit_Title_Ftp_Settings",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpShareName",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpUserName",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpPasswd",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpPassive",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpBlockSize",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpPort",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpTimeout",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+ {name => "FtpFollowSymlinks",
+ visible => sub { return $_[0]->{XferMethod} eq "ftp"; } },
+
+
+ ### Archive Settings
{text => "CfgEdit_Title_Archive_Settings",
visible => sub { return $_[0]->{XferMethod} eq "archive"; } },
{name => "ArchiveDest",
{name => "ArchiveSplit",
visible => sub { return $_[0]->{XferMethod} eq "archive"; } },
+ ### Include/Exclude Settings
{text => "CfgEdit_Title_Include_Exclude",
visible => sub { return $_[0]->{XferMethod} ne "archive"; } },
{name => "BackupFilesOnly",
{name => "BackupFilesExclude",
visible => sub { return $_[0]->{XferMethod} ne "archive"; } },
+ ### Samba paths and commands
{text => "CfgEdit_Title_Smb_Paths_Commands",
visible => sub { return $_[0]->{XferMethod} eq "smb"; } },
{name => "SmbClientPath",
{name => "SmbClientRestoreCmd",
visible => sub { return $_[0]->{XferMethod} eq "smb"; } },
+ ### Tar paths and commands
{text => "CfgEdit_Title_Tar_Paths_Commands",
visible => sub { return $_[0]->{XferMethod} eq "tar"; } },
{name => "TarClientPath",
{name => "TarClientRestoreCmd",
visible => sub { return $_[0]->{XferMethod} eq "tar"; } },
+ ### Rsync paths and commands
{text => "CfgEdit_Title_Rsync_Paths_Commands_Args",
visible => sub { return $_[0]->{XferMethod} eq "rsync"; } },
{text => "CfgEdit_Title_Rsyncd_Port_Args",
visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
{name => "RsyncArgs",
visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
+ {name => "RsyncArgsExtra",
+ visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
{name => "RsyncRestoreArgs",
visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
+ ### Archive paths and commands
{text => "CfgEdit_Title_Archive_Paths_Commands",
visible => sub { return $_[0]->{XferMethod} eq "archive"; } },
{name => "ArchiveClientCmd",
{name => "IncrKeepCnt"},
{name => "IncrKeepCntMin"},
{name => "IncrAgeMax"},
+ {name => "IncrLevels"},
{name => "IncrFill"},
{text => "CfgEdit_Title_Blackouts"},
+ {name => "BackupsDisable"},
{name => "BlackoutBadPingLimit"},
{name => "BlackoutGoodCnt"},
{name => "BlackoutPeriods"},
{name => "RestorePostUserCmd"},
{name => "ArchivePreUserCmd"},
{name => "ArchivePostUserCmd"},
+ {name => "UserCmdCheckStatus"},
],
},
hosts => {
ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_edit_config_files}}"));
}
- if ( defined($In{menu}) || $In{editAction} eq $Lang->{CfgEdit_Button_Save} ) {
+ if ( defined($In{menu}) || $In{saveAction} eq "Save" ) {
$errors = errorCheck();
if ( %$errors ) {
#
# If there are errors, then go back to the same menu
#
- $In{editAction} = "";
- $In{newMenu} = "";
+ $In{saveAction} = "";
+ #$In{newMenu} = "";
}
if ( (my $var = $In{overrideUncheck}) ne "" ) {
#
- # a compound variable was unchecked; delete extra
- # variables to make the shape the same.
+ # a compound variable was unchecked; delete or
+ # add extra variables to make the shape the same.
#
#print STDERR Dumper(\%In);
foreach my $v ( keys(%In) ) {
- next if ( $v !~ /^v_z_(\Q$var\E(_z_.*|$))/ );
- delete($In{$v}) if ( !defined($In{"orig_z_$1"}) );
+ if ( $v =~ /^v_zZ_(\Q$var\E(_zZ_.*|$))/ ) {
+ delete($In{$v}) if ( !defined($In{"orig_zZ_$1"}) );
+ }
+ if ( $v =~ /^orig_zZ_(\Q$var\E(_zZ_.*|$))/ ) {
+ $In{"v_zZ_$1"} = $In{$v};
+ }
}
delete($In{"vflds.$var"});
}
$newConf = { %$mainConf, %$hostConf };
}
- if ( $In{editAction} ne $Lang->{CfgEdit_Button_Save} && $In{newMenu} ne ""
+ if ( $In{saveAction} ne "Save" && $In{newMenu} ne ""
&& defined($ConfigMenu{$In{newMenu}}) ) {
$menu = $In{newMenu};
}
$content .= eval("qq($Lang->{CfgEdit_Header_Host})");
}
- my $saveDisplay = "block";
- $saveDisplay = "none" if ( !$In{modified}
- || $In{editAction} eq $Lang->{CfgEdit_Button_Save} );
+ my $saveStyle = "";
+ my $saveColor = "#ff0000";
+
+ if ( $In{modified} && $In{saveAction} ne "Save" && !%$errors ) {
+ $saveStyle = "style=\"color:$saveColor\"";
+ } else {
+ $In{modified} = 0;
+ }
+
#
# Add action and host to the URL so the nav bar link is
# highlighted
<table border="0" cellpadding="2">
<tr>$groupText</tr>
<tr>
-<form method="post" name="form1" action="$url">
+<form method="post" name="editForm" action="$url">
<input type="hidden" name="host" value="$host">
<input type="hidden" name="menu" value="$menu">
<input type="hidden" name="newMenu" value="">
<input type="hidden" name="overrideUncheck" value="">
<input type="hidden" name="addVar" value="">
<input type="hidden" name="action" value="editConfig">
-<input type="submit" class="editSaveButton" style="display: $saveDisplay" name="editAction" value="${EscHTML($Lang->{CfgEdit_Button_Save})}">
+<input type="hidden" name="saveAction" value="">
+<input type="button" class="editSaveButton" name="editAction"
+ value="${EscHTML($Lang->{CfgEdit_Button_Save})}" $saveStyle
+ onClick="saveSubmit();">
+<p>
<script language="javascript" type="text/javascript">
<!--
+ function saveSubmit()
+ {
+ if ( document.editForm.modified.value != 0 ) {
+ document.editForm.saveAction.value = 'Save';
+ document.editForm.submit();
+ }
+ return false;
+ }
+
function deleteSubmit(varName)
{
- document.form1.deleteVar.value = varName;
- document.form1.modified.value = 1;
- document.form1.submit();
+ document.editForm.deleteVar.value = varName;
+ document.editForm.modified.value = 1;
+ document.editForm.submit();
return;
}
function insertSubmit(varName)
{
- document.form1.insertVar.value = varName;
- document.form1.modified.value = 1;
- document.form1.submit();
+ document.editForm.insertVar.value = varName;
+ document.editForm.modified.value = 1;
+ document.editForm.submit();
return;
}
function addSubmit(varName, checkKey)
{
if ( checkKey
- && eval("document.form1.addVarKey_" + varName + ".value") == "" ) {
+ && eval("document.editForm.addVarKey_" + varName + ".value") == "" ) {
alert("New key must be non-empty");
return;
}
- document.form1.addVar.value = varName;
- document.form1.modified.value = 1;
- document.form1.submit();
+ document.editForm.addVar.value = varName;
+ document.editForm.modified.value = 1;
+ document.editForm.submit();
return;
}
function menuSubmit(menuName)
{
- document.form1.newMenu.value = menuName;
- document.form1.submit();
+ document.editForm.newMenu.value = menuName;
+ document.editForm.submit();
}
function varChange(varName)
{
- document.form1.editAction.style.display = "block";
- document.form1.modified.value = 1;
+ document.editForm.modified.value = 1;
+ document.editForm.editAction.style.color = '$saveColor';
}
function checkboxChange(varName)
{
- document.form1.editAction.style.display = "block";
- document.form1.modified.value = 1;
+ document.editForm.modified.value = 1;
+ document.editForm.editAction.style.color = '$saveColor';
// Do nothing if the checkbox is now set
- if ( eval("document.form1.override_" + varName + ".checked") ) {
+ if ( eval("document.editForm.override_" + varName + ".checked") ) {
return false;
}
var allVars = {};
- var varRE = new RegExp("^v_z_(" + varName + ".*)");
- var origRE = new RegExp("^orig_z_(" + varName + ".*)");
- for ( var i = 0 ; i < document.form1.elements.length ; i++ ) {
- var e = document.form1.elements[i];
+ var varRE = new RegExp("^v_zZ_(" + varName + ".*)");
+ var origRE = new RegExp("^orig_zZ_(" + varName + ".*)");
+ for ( var i = 0 ; i < document.editForm.elements.length ; i++ ) {
+ var e = document.editForm.elements[i];
var re;
if ( (re = varRE.exec(e.name)) != null ) {
if ( allVars[re[1]] == null ) {
allVars[re[1]] = 0;
}
allVars[re[1]]++;
- //debugMsg("found v_z_ match with " + re[1]);
+ //debugMsg("found v_zZ_ match with " + re[1]);
//debugMsg("allVars[" + re[1] + "] = " + allVars[re[1]]);
} else if ( (re = origRE.exec(e.name)) != null ) {
if ( allVars[re[1]] == null ) {
} else {
// copy the original variable values
//debugMsg("setting " + v);
- eval("document.form1.v_z_" + v + ".value = document.form1.orig_z_" + v + ".value");
+ eval("document.editForm.v_zZ_" + v + ".value = document.editForm.orig_zZ_" + v + ".value");
}
}
if ( sameShape ) {
} else {
// need to rebuild the form since the compound variable
// has changed shape
- document.form1.overrideUncheck.value = varName;
- document.form1.submit();
+ document.editForm.overrideUncheck.value = varName;
+ document.editForm.submit();
return false;
}
}
function checkboxSet(varName)
{
- document.form1.editAction.style.display = "block";
- document.form1.modified.value = 1;
- eval("document.form1.override_" + varName + ".checked = 1;");
+ document.editForm.modified.value = 1;
+ document.editForm.editAction.style.color = '$saveColor';
+ eval("document.editForm.override_" + varName + ".checked = 1;");
return false;
}
EOF
my $doneParam = {};
+ my $tblContent;
#
# There is a special case of the user deleting just the field
if ( $In{deleteVar} ne "" && %$errors > 0 ) {
my $matchAll = 1;
foreach my $v ( keys(%$errors) ) {
- if ( $v ne $In{deleteVar} && $v !~ /^\Q$In{deleteVar}_z_/ ) {
+ if ( $v ne $In{deleteVar} && $v !~ /^\Q$In{deleteVar}_zZ_/ ) {
$matchAll = 0;
last;
}
my $isError = %$errors;
- if ( !$isError && $In{editAction} eq $Lang->{CfgEdit_Button_Save} ) {
+ if ( !$isError && $In{saveAction} eq "Save" ) {
my($mesg, $err);
if ( $host ne "" ) {
$hostConf = $bpc->ConfigDataRead($host) if ( !defined($hostConf) );
($mesg, my $hostChange) = hostsDiffMesg($hostsNew);
$bpc->HostInfoWrite($hostsNew) if ( $hostChange );
foreach my $host ( keys(%$copyConf) ) {
- my $confData = $bpc->ConfigDataRead($copyConf->{$host});
+ #
+ # Currently host names are forced to lc when they
+ # are read from the hosts file. Therefore we need
+ # to force the from and to hosts to lc.
+ #
+ my $confData = $bpc->ConfigDataRead(lc($copyConf->{$host}));
my $fromHost = $copyConf->{$host};
- $err .= $bpc->ConfigDataWrite($host, $confData);
+ $err .= $bpc->ConfigDataWrite(lc($host), $confData);
$mesg .= eval("qq($Lang->{CfgEdit_Log_Copy_host_config})");
}
$newConf->{Hosts} = $hostsSave;
}
if ( defined($err) ) {
- $content .= <<EOF;
+ $tblContent .= <<EOF;
<tr><td colspan="2" class="border"><span class="editError">$err</span></td></tr>
EOF
}
$bpc->ServerConnect();
if ( $mesg ne "" ) {
(my $mesgBR = $mesg) =~ s/\n/<br>\n/g;
- $content .= <<EOF;
-<tr><td colspan="2" class="border"><span class="editComment">$mesgBR</span></td></tr>
-EOF
+ # uncomment this if you want the changes to be displayed
+# $tblContent .= <<EOF;
+#<tr><td colspan="2" class="border"><span class="editComment">$mesgBR</span></td></tr>
+#EOF
foreach my $str ( split(/\n/, $mesg) ) {
$bpc->ServerMesg("log $str") if ( $str ne "" );
}
next if ( $disabled || $menuDisable{$menu}{top} );
if ( ref($paramInfo->{visible}) eq "CODE"
- && !&{$paramInfo->{visible}}($newConf) ) {
+ && !&{$paramInfo->{visible}}($newConf, $bpc) ) {
next;
}
if ( defined($paramInfo->{text}) ) {
my $text = eval("qq($Lang->{$paramInfo->{text}})");
- $content .= <<EOF;
+ $tblContent .= <<EOF;
<tr><td colspan="2" class="editHeader">$text</td></tr>
EOF
next;
$doneParam->{$param} = 1;
- $content .= fieldEditBuild($ConfigMeta{$param},
+ $tblContent .= fieldEditBuild($ConfigMeta{$param},
$param,
$newConf->{$param},
$errors,
if ( defined($paramInfo->{comment}) ) {
my $topDir = $bpc->TopDir;
my $text = eval("qq($Lang->{$paramInfo->{comment}})");
- $content .= <<EOF;
+ $tblContent .= <<EOF;
<tr><td colspan="2" class="editComment">$text</td></tr>
EOF
}
}
#
- # Emit any remaining errors - should not happen
+ # Emit a summary of all the errors
#
+ my $errorTxt;
+
+ if ( %$errors ) {
+ $errorTxt .= <<EOF;
+<tr><td colspan="2" class="border"><span class="editError">$Lang->{CfgEdit_Error_No_Save}</span></td></tr>
+EOF
+ }
+
foreach my $param ( sort(keys(%$errors)) ) {
- $content .= <<EOF;
+ $errorTxt .= <<EOF;
<tr><td colspan="2" class="border"><span class="editError">$errors->{$param}</span></td></tr>
EOF
- delete($errors->{$param});
}
$content .= <<EOF;
+$errorTxt
+$tblContent
</table>
EOF
$doneParam->{$param} = 1;
}
- if ( defined($In{menu}) || $In{editAction} eq $Lang->{CfgEdit_Button_Save} ) {
- if ( $In{editAction} eq $Lang->{CfgEdit_Button_Save}
- && !$userHost ) {
+ if ( defined($In{menu}) || $In{saveAction} eq "Save" ) {
+ if ( $In{saveAction} eq "Save" && !$userHost ) {
#
- # Emit the new settings as orig_z_ parameters
+ # Emit the new settings as orig_zZ_ parameters
#
$doneParam = {};
foreach my $param ( keys(%ConfigMeta) ) {
}
} else {
#
- # Just switching menus: copy all the orig_z_ input parameters
+ # Just switching menus: copy all the orig_zZ_ input parameters
#
foreach my $var ( keys(%In) ) {
- next if ( $var !~ /^orig_z_/ );
+ next if ( $var !~ /^orig_zZ_/ );
+ my $val = decode_utf8($In{$var});
$contentHidden .= <<EOF;
-<input type="hidden" name="$var" value="${EscHTML($In{$var})}">
+<input type="hidden" name="$var" value="${EscHTML($val)}">
EOF
}
}
$varValue = [$varValue] if ( ref($varValue) ne "ARRAY" );
for ( my $i = 0 ; $i < @$varValue ; $i++ ) {
- $content .= fieldHiddenBuild($type->{child}, "${varName}_z_$i",
+ $content .= fieldHiddenBuild($type->{child}, "${varName}_zZ_$i",
$varValue->[$i], $prefix);
}
} elsif ( $type->{type} eq "hash" || $type->{type} eq "horizHash" ) {
<input type="hidden" name="vflds.$varName" value="${EscHTML($fld)}">
EOF
}
- $content .= fieldHiddenBuild($childType, "${varName}_z_$fld",
+ $content .= fieldHiddenBuild($childType, "${varName}_zZ_$fld",
$varValue->{$fld}, $prefix);
}
} elsif ( $type->{type} eq "shortlist" ) {
$varValue = [$varValue] if ( ref($varValue) ne "ARRAY" );
$varValue = join(", ", @$varValue);
$content .= <<EOF;
-<input type="hidden" name="${prefix}_z_$varName" value="${EscHTML($varValue)}">
+<input type="hidden" name="${prefix}_zZ_$varName" value="${EscHTML($varValue)}">
EOF
} else {
$content .= <<EOF;
-<input type="hidden" name="${prefix}_z_$varName" value="${EscHTML($varValue)}">
+<input type="hidden" name="${prefix}_zZ_$varName" value="${EscHTML($varValue)}">
EOF
}
return $content;
$size = $type->{size} if ( defined($type->{size}) );
#
- # These fragments allow inline conent to be turned on and off
+ # These fragments allow inline content to be turned on and off
#
# <tr><td colspan="2"><span id="id_$varName" style="display: none" class="editComment">$comment</span></td></tr>
# <tr><td class="border"><a href="javascript: displayHelp('$varName')">$varName</a>
if ( $level == 0 ) {
my $lcVarName = lc($varName);
$content .= <<EOF;
-<tr><td class="border"><a href="?action=view&type=docs#item_%24conf%7b$lcVarName%7d">$varName</a>
+<tr><td class="border"><a href="?action=view&type=docs#_conf_${lcVarName}_">$varName</a>
EOF
if ( defined($overrideVar) ) {
my $override_checked = "";
- if ( !$isError && $In{deleteVar} =~ /^\Q${varName}_z_/
- || !$isError && $In{insertVar} =~ /^\Q${varName}\E(_z_|$)/
- || !$isError && $In{addVar} =~ /^\Q${varName}\E(_z_|$)/ ) {
+ if ( !$isError && $In{deleteVar} =~ /^\Q${varName}_zZ_/
+ || !$isError && $In{insertVar} =~ /^\Q${varName}\E(_zZ_|$)/
+ || !$isError && $In{addVar} =~ /^\Q${varName}\E(_zZ_|$)/ ) {
$overrideSet = 1;
}
if ( $overrideSet ) {
$content .= "<td class=\"border\">\n";
$varValue = [] if ( !defined($varValue) );
$varValue = [$varValue] if ( ref($varValue) ne "ARRAY" );
- if ( !$isError && $In{deleteVar} =~ /^\Q${varName}_z_\E(\d+)$/
+ if ( !$isError && $In{deleteVar} =~ /^\Q${varName}_zZ_\E(\d+)$/
&& $1 < @$varValue ) {
#
# User deleted entry in this array
splice(@$varValue, $1, 1) if ( @$varValue > 1 || $type->{emptyOk} );
$In{deleteVar} = "";
}
- if ( !$isError && $In{insertVar} =~ /^\Q${varName}_z_\E(\d+)$/
+ if ( !$isError && $In{insertVar} =~ /^\Q${varName}_zZ_\E(\d+)$/
&& $1 < @$varValue ) {
#
# User inserted entry in this array
$In{addVar} = "";
}
$content .= "<table border=\"1\" cellspacing=\"0\">\n";
+ my $colspan;
if ( ref($type) eq "HASH" && ref($type->{child}) eq "HASH"
&& $type->{child}{type} eq "horizHash" ) {
}
$content .= "<tr><td class=\"border\"></td>\n";
for ( my $i = 0 ; $i < @order ; $i++ ) {
- $content .= "<td>$order[$i]</td>\n";
+ $content .= "<td class=\"tableheader\">$order[$i]</td>\n";
}
+ $colspan = @order + 1;
$content .= "</tr>\n";
for ( my $i = 0 ; $i < @$varValue ; $i++ ) {
if ( @$varValue > 1 || $type->{emptyOk} ) {
$content .= <<EOF;
<td class="border">
-<input type="button" name="del_${varName}_z_$i" value="${EscHTML($Lang->{CfgEdit_Button_Delete})}"
- onClick="deleteSubmit('${varName}_z_$i')">
+<input type="button" name="del_${varName}_zZ_$i" value="${EscHTML($Lang->{CfgEdit_Button_Delete})}"
+ onClick="deleteSubmit('${varName}_zZ_$i')">
</td>
EOF
}
- $content .= fieldEditBuild($type->{child}, "${varName}_z_$i",
+ $content .= fieldEditBuild($type->{child}, "${varName}_zZ_$i",
$varValue->[$i], $errors, $level + 1, undef,
$isError, $onchangeSubmit,
$overrideVar, $overrideSet);
for ( my $i = 0 ; $i < @$varValue ; $i++ ) {
$content .= <<EOF;
<tr><td class="border">
-<input type="button" name="ins_${varName}_z_$i" value="${EscHTML($Lang->{CfgEdit_Button_Insert})}"
- onClick="insertSubmit('${varName}_z_$i')">
+<input type="button" name="ins_${varName}_zZ_$i" value="${EscHTML($Lang->{CfgEdit_Button_Insert})}"
+ onClick="insertSubmit('${varName}_zZ_$i')">
EOF
if ( @$varValue > 1 || $type->{emptyOk} ) {
$content .= <<EOF;
-<input type="button" name="del_${varName}_z_$i" value="${EscHTML($Lang->{CfgEdit_Button_Delete})}"
- onClick="deleteSubmit('${varName}_z_$i')">
+<input type="button" name="del_${varName}_zZ_$i" value="${EscHTML($Lang->{CfgEdit_Button_Delete})}"
+ onClick="deleteSubmit('${varName}_zZ_$i')">
EOF
}
$content .= "</td>\n";
- $content .= fieldEditBuild($type->{child}, "${varName}_z_$i",
+ $content .= fieldEditBuild($type->{child}, "${varName}_zZ_$i",
$varValue->[$i], $errors, $level + 1, undef,
$isError, $onchangeSubmit,
$overrideVar, $overrideSet);
$content .= "</tr>\n";
}
+ $colspan = 2;
}
$content .= <<EOF;
-<tr><td class="border"><input type="button" name="add_$varName" value="${EscHTML($Lang->{CfgEdit_Button_Add})}"
+<tr><td class="border" colspan="$colspan"><input type="button" name="add_$varName" value="${EscHTML($Lang->{CfgEdit_Button_Add})}"
onClick="addSubmit('$varName')"></td></tr>
</table>
EOF
$varValue = {} if ( ref($varValue) ne "HASH" );
if ( !$isError && !$type->{noKeyEdit}
- && $In{deleteVar} !~ /^\Q${varName}_z_\E.*_z_/
- && $In{deleteVar} =~ /^\Q${varName}_z_\E(\w+)$/ ) {
+ && $In{deleteVar} !~ /^\Q${varName}_zZ_\E.*_zZ_/
+ && $In{deleteVar} =~ /^\Q${varName}_zZ_\E(.*)$/ ) {
#
# User deleted entry in this hash
#
if ( !$type->{noKeyEdit}
&& (keys(%$varValue) > 1 || $type->{emptyOk}) ) {
$content .= <<EOF;
-<input type="submit" name="del_${varName}_z_$fld" value="${EscHTML($Lang->{CfgEdit_Button_Delete})}"
- onClick="deleteSubmit('${varName}_z_$fld')">
+<input type="submit" name="del_${varName}_zZ_$fld" value="${EscHTML($Lang->{CfgEdit_Button_Delete})}"
+ onClick="deleteSubmit('${varName}_zZ_$fld')">
EOF
}
if ( defined($type->{child}) ) {
EOF
}
$content .= "</td>\n";
- $content .= fieldEditBuild($childType, "${varName}_z_$fld",
+ $content .= fieldEditBuild($childType, "${varName}_zZ_$fld",
$varValue->{$fld}, $errors, $level + 1, undef,
$isError, $onchangeSubmit,
$overrideVar, $overrideSet);
if ( !$type->{noKeyEdit} ) {
$content .= <<EOF;
<tr><td class="border" colspan="2">
-New key: <input type="text" name="addVarKey_$varName" size="20" maxlength="256" value="">
+$Lang->{CfgEdit_Button_New_Key}: <input type="text" class="editTextInput" name="addVarKey_$varName" size="20" maxlength="256" value="">
<input type="button" name="add_$varName" value="${EscHTML($Lang->{CfgEdit_Button_Add})}" onClick="addSubmit('$varName', 1)">
</td></tr>
EOF
<input type="hidden" name="vflds.$varName" value="${EscHTML($fld)}">
EOF
}
- $content .= fieldEditBuild($childType, "${varName}_z_$fld",
+ $content .= fieldEditBuild($childType, "${varName}_zZ_$fld",
$varValue->{$fld}, $errors, $level + 1, undef,
$isError, $onchangeSubmit,
$overrideVar, $overrideSet);
# in %In, rather than the parsed values in $varValue.
# This is so that the user's erroneous input is preserved.
#
- $varValue = $In{"v_z_$varName"} if ( defined($In{"v_z_$varName"}) );
+ $varValue = $In{"v_zZ_$varName"} if ( defined($In{"v_zZ_$varName"}) );
}
if ( defined($errors->{$varName}) ) {
$content .= <<EOF;
<span class="editError">$errors->{$varName}</span><br>
EOF
- delete($errors->{$varName});
}
my $onChange;
if ( defined($overrideVar) ) {
$onChange .= "checkboxSet('$overrideVar');";
} else {
- $onChange .= "varChange('$overrideVar');";
+ $onChange .= "varChange('$varName');";
}
if ( $onchangeSubmit ) {
- $onChange .= "document.form1.submit();";
+ $onChange .= "document.editForm.submit();";
}
if ( $onChange ne "" ) {
$onChange = " onChange=\"$onChange\"";
}
my $textType = ($varName =~ /Passwd/) ? "password" : "text";
$content .= <<EOF;
-<input type="$textType" name="v_z_$varName" size="$size" maxlength="256" value="${EscHTML($varValue)}"$onChange>
+<input type="$textType" class="editTextInput" name="v_zZ_$varName" size="$size" maxlength="256" value="${EscHTML($varValue)}"$onChange>
EOF
} elsif ( $type->{type} eq "boolean" ) {
# checkbox
my $checked = "checked" if ( $varValue );
$content .= <<EOF;
-<input type="checkbox" name="v_z_$varName" $checked value="1"$onChange>
+<input type="checkbox" name="v_zZ_$varName" $checked value="1"$onChange>
EOF
} elsif ( $type->{type} eq "select" ) {
$content .= <<EOF;
-<select name="v_z_$varName"$onChange>
+<select name="v_zZ_$varName"$onChange>
EOF
foreach my $option ( @{$type->{values}} ) {
my $sel = " selected" if ( $varValue eq $option );
my $rowCnt = $varValue =~ tr/\n//;
$rowCnt = 1 if ( $rowCnt < 1 );
$content .= <<EOF;
-<textarea name="v_z_$varName" cols="$size" rows="$rowCnt"$onChange>${EscHTML($varValue)}</textarea>
+<textarea name="v_zZ_$varName" class="editTextArea" cols="$size" rows="$rowCnt"$onChange>${EscHTML($varValue)}</textarea>
EOF
}
$content .= "</td>\n";
if ( $type->{type} eq "list" ) {
for ( my $i = 0 ; ; $i++ ) {
- last if ( fieldErrorCheck($type->{child}, "${varName}_z_$i", $errors) );
+ last if ( fieldErrorCheck($type->{child}, "${varName}_zZ_$i", $errors) );
}
} elsif ( $type->{type} eq "hash" || $type->{type} eq "horizHash" ) {
my(@order, $childType);
} else {
$childType = $type->{childType};
}
- $ret ||= fieldErrorCheck($childType, "${varName}_z_$fld", $errors);
+ $ret ||= fieldErrorCheck($childType, "${varName}_zZ_$fld", $errors);
}
return $ret;
} else {
- $In{"v_z_$varName"} = "0" if ( $type->{type} eq "boolean"
- && $In{"v_z_$varName"} eq "" );
+ $In{"v_zZ_$varName"} = "0" if ( $type->{type} eq "boolean"
+ && $In{"v_zZ_$varName"} eq "" );
- return 1 if ( !exists($In{"v_z_$varName"}) );
+ return 1 if ( !exists($In{"v_zZ_$varName"}) );
- (my $var = $varName) =~ s/_z_/./g;
+ (my $var = $varName) =~ s/_zZ_/./g;
if ( $type->{type} eq "integer"
|| $type->{type} eq "boolean" ) {
- if ( $In{"v_z_$varName"} !~ /^-?\d+\s*$/s
- && $In{"v_z_$varName"} ne "" ) {
+ if ( $In{"v_zZ_$varName"} !~ /^-?\d+\s*$/s
+ && $In{"v_zZ_$varName"} ne "" ) {
$errors->{$varName} = eval("qq{$Lang->{CfgEdit_Error__must_be_an_integer}}");
}
} elsif ( $type->{type} eq "float" ) {
- if ( $In{"v_z_$varName"} !~ /^-?\d*(\.\d*)?\s*$/s
- && $In{"v_z_$varName"} ne "" ) {
+ if ( $In{"v_zZ_$varName"} !~ /^-?\d*(\.\d*)?\s*$/s
+ && $In{"v_zZ_$varName"} ne "" ) {
$errors->{$varName}
= eval("qq{$Lang->{CfgEdit_Error__must_be_real_valued_number}}");
}
} elsif ( $type->{type} eq "shortlist" ) {
- my @vals = split(/[,\s]+/, $In{"v_z_$varName"});
+ my @vals = split(/[,\s]+/, $In{"v_zZ_$varName"});
for ( my $i = 0 ; $i < @vals ; $i++ ) {
if ( $type->{child} eq "integer"
&& $vals[$i] !~ /^-?\d+\s*$/s
} elsif ( $type->{type} eq "select" ) {
my $match = 0;
foreach my $option ( @{$type->{values}} ) {
- if ( $In{"v_z_$varName"} eq $option ) {
+ if ( $In{"v_zZ_$varName"} eq $option ) {
$match = 1;
last;
}
$errors->{$varName} = eval("qq{$Lang->{CfgEdit_Error__must_be_valid_option}}")
if ( !$match );
} elsif ( $type->{type} eq "execPath" ) {
- if ( $In{"v_z_$varName"} ne "" && !-x $In{"v_z_$varName"} ) {
+ if ( $In{"v_zZ_$varName"} ne "" && !-x $In{"v_zZ_$varName"} ) {
$errors->{$varName} = eval("qq{$Lang->{CfgEdit_Error__must_be_executable_program}}");
}
} else {
$$value = [];
for ( my $i = 0 ; ; $i++ ) {
my $val;
- last if ( fieldInputParse($type->{child}, "${varName}_z_$i", \$val) );
+ last if ( fieldInputParse($type->{child}, "${varName}_zZ_$i", \$val) );
push(@$$value, $val);
}
$$value = undef if ( $type->{undefIfEmpty} && @$$value == 0 );
} else {
$childType = $type->{childType};
}
- $ret ||= fieldInputParse($childType, "${varName}_z_$fld", \$val);
+ $ret ||= fieldInputParse($childType, "${varName}_zZ_$fld", \$val);
last if ( $ret );
$$value->{$fld} = $val;
}
return $ret;
} else {
if ( $type->{type} eq "boolean" ) {
- $$value = 0 + $In{"v_z_$varName"};
- } elsif ( !exists($In{"v_z_$varName"}) ) {
+ $$value = 0 + $In{"v_zZ_$varName"};
+ } elsif ( !exists($In{"v_zZ_$varName"}) ) {
return 1;
}
+ my $v = $In{"v_zZ_$varName"};
+
if ( $type->{type} eq "integer" ) {
- $$value = 0 + $In{"v_z_$varName"};
+ if ( $v =~ /^-?\d+\s*$/s || $v eq "" ) {
+ $$value = 0 + $v;
+ } else {
+ # error value - keep in string form
+ $$value = $v;
+ }
} elsif ( $type->{type} eq "float" ) {
- $$value = 0 + $In{"v_z_$varName"};
+ if ( $v =~ /^-?\d*(\.\d*)?\s*$/s || $v eq "" ) {
+ $$value = 0 + $v;
+ } else {
+ # error value - keep in string form
+ $$value = $v;
+ }
} elsif ( $type->{type} eq "shortlist" ) {
- $$value = [split(/[,\s]+/, $In{"v_z_$varName"})];
- if ( $type->{child} eq "float"
- || $type->{child} eq "integer"
- || $type->{child} eq "boolean" ) {
+ $$value = [split(/[,\s]+/, $v)];
+ if ( $type->{child} eq "float" ) {
foreach ( @$$value ) {
- $_ += 0;
+ if ( /^-?\d*(\.\d*)?\s*$/s || $v eq "" ) {
+ $_ += 0;
+ }
+ }
+ } elsif ( $type->{child} eq "integer"
+ || $type->{child} eq "boolean" ) {
+ foreach ( @$$value ) {
+ if ( /^-?\d+\s*$/s || $v eq "" ) {
+ $_ += 0;
+ }
}
}
} else {
- $$value = $In{"v_z_$varName"};
+ $$value = decode_utf8($In{"v_zZ_$varName"});
$$value =~ s/\r\n/\n/g;
+ # remove leading space from exec paths
+ $$value =~ s/^\s+// if ( $type->{type} eq "execPath" );
}
$$value = undef if ( $type->{undefIfEmpty} && $$value eq "" );
}
my $value = $dump->Dump;
$value =~ s/\n/\\n/g;
$value =~ s/\r/\\r/g;
+ if ( $p =~ /Passwd/ || $p =~ /Secret/ ) {
+ $value = "'*'";
+ }
+
$mesg .= eval("qq($Lang->{CfgEdit_Log_Add_param_value})");
} else {
my $dump = Data::Dumper->new([$newConf->{$p}]);
(my $valueNew2 = $valueNew) =~ s/['\n\r]//g;
(my $valueOld2 = $valueOld) =~ s/['\n\r]//g;
+
+ next if ( $valueOld2 eq $valueNew2 );
+
$valueNew =~ s/\n/\\n/g;
$valueOld =~ s/\n/\\n/g;
$valueNew =~ s/\r/\\r/g;
$valueOld =~ s/\r/\\r/g;
- $mesg .= eval("qq($Lang->{CfgEdit_Log_Change_param_value})")
- if ( $valueOld2 ne $valueNew2 );
+ if ( $p =~ /Passwd/ || $p =~ /Secret/ ) {
+ $valueNew = "'*'";
+ $valueOld = "'*'";
+ }
+
+ $mesg .= eval("qq($Lang->{CfgEdit_Log_Change_param_value})");
}
}
return $mesg;