📄 editconfig.pm
字号:
#============================================================= -*-perl-*-## BackupPC::CGI::EditConfig package## DESCRIPTION## This module implements the EditConfig action for the CGI interface.## AUTHOR# Craig Barratt <cbarratt@users.sourceforge.net>## COPYRIGHT# Copyright (C) 2005-2007 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# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA##========================================================================## Version 3.1.0, released 25 Nov 2007.## See http://backuppc.sourceforge.net.##========================================================================package BackupPC::CGI::EditConfig;use strict;use BackupPC::CGI::Lib qw(:all);use BackupPC::Config::Meta qw(:all);use BackupPC::Storage;use Data::Dumper;use Encode;our %ConfigMenu = ( server => { text => "CfgEdit_Title_Server", param => [ {text => "CfgEdit_Title_General_Parameters"}, {name => "ServerHost"}, {name => "BackupPCUser"}, {name => "BackupPCUserVerify"}, {name => "MaxOldLogFiles"}, {name => "TrashCleanSleepSec"}, {text => "CfgEdit_Title_Wakeup_Schedule"}, {name => "WakeupSchedule"}, {text => "CfgEdit_Title_Concurrent_Jobs"}, {name => "MaxBackups"}, {name => "MaxUserBackups"}, {name => "MaxPendingCmds"}, {name => "MaxBackupPCNightlyJobs"}, {name => "BackupPCNightlyPeriod"}, {text => "CfgEdit_Title_Pool_Filesystem_Limits"}, {name => "DfCmd"}, {name => "DfMaxUsagePct"}, {name => "HardLinkMax"}, {text => "CfgEdit_Title_Other_Parameters"}, {name => "UmaskMode"}, {name => "MyPath"}, {name => "DHCPAddressRanges"}, {name => "PerlModuleLoad"}, {name => "ServerInitdPath"}, {name => "ServerInitdStartCmd"}, {text => "CfgEdit_Title_Remote_Apache_Settings"}, {name => "ServerPort"}, {name => "ServerMesgSecret"}, {text => "CfgEdit_Title_Program_Paths"}, {name => "SshPath"}, {name => "NmbLookupPath"}, {name => "PingPath"}, {name => "DfPath"}, {name => "SplitPath"}, {name => "ParPath"}, {name => "CatPath"}, {name => "GzipPath"}, {name => "Bzip2Path"}, {text => "CfgEdit_Title_Install_Paths"}, # # 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"}, # # Cannot edit ConfDir or InstallDir, since the real value is hardcoded in # lib/BackupPC/Lib.pm. # {name => "ConfDir"}, # {name => "InstallDir"}, # ], }, email => { text => "CfgEdit_Title_Email", param => [ {text => "CfgEdit_Title_Email_settings"}, {name => "SendmailPath"}, {name => "EMailNotifyMinDays"}, {name => "EMailFromUserName"}, {name => "EMailAdminUserName"}, {name => "EMailUserDestDomain"}, {text => "CfgEdit_Title_Email_User_Messages"}, {name => "EMailNoBackupEverSubj"}, {name => "EMailNoBackupEverMesg"}, {name => "EMailNotifyOldBackupDays"}, {name => "EMailNoBackupRecentSubj"}, {name => "EMailNoBackupRecentMesg"}, {name => "EMailNotifyOldOutlookDays"}, {name => "EMailOutlookBackupSubj"}, {name => "EMailOutlookBackupMesg"}, {name => "EMailHeaders"}, ], }, cgi => { text => "CfgEdit_Title_CGI", param => [ {text => "CfgEdit_Title_Admin_Privileges"}, {name => "CgiAdminUserGroup"}, {name => "CgiAdminUsers"}, {text => "CfgEdit_Title_Page_Rendering"}, {name => "Language"}, {name => "CgiNavBarAdminAllHosts"}, {name => "CgiSearchBoxEnable"}, {name => "CgiNavBarLinks"}, {name => "CgiStatusHilightColor"}, {name => "CgiDateFormatMMDD"}, {name => "CgiHeaders"}, {name => "CgiExt2ContentType"}, {name => "CgiCSSFile"}, {text => "CfgEdit_Title_Paths"}, {name => "CgiURL"}, {name => "CgiImageDir"}, {name => "CgiImageDirURL"}, {text => "CfgEdit_Title_User_URLs"}, {name => "CgiUserHomePageCheck"}, {name => "CgiUserUrlCreate"}, {text => "CfgEdit_Title_User_Config_Editing"}, {name => "CgiUserConfigEditEnable"}, {name => "CgiUserConfigEdit"}, ], }, xfer => { text => "CfgEdit_Title_Xfer", param => [ {text => "CfgEdit_Title_Xfer_Settings"}, {name => "XferMethod", onchangeSubmit => 1}, {name => "XferLogLevel"}, {name => "ClientCharset"}, {name => "ClientCharsetLegacy"}, {text => "CfgEdit_Title_Smb_Settings", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbShareName", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbShareUserName", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbSharePasswd", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {text => "CfgEdit_Title_Tar_Settings", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarShareName", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {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", visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } }, {name => "RsyncCsumCacheVerifyProb", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, {text => "CfgEdit_Title_BackupPCd_Settings", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, {name => "BackupPCdShareName", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, {name => "BackupPCdPath", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, {name => "BackupPCdCmd", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, {name => "BackupPCdRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, {text => "CfgEdit_Title_Archive_Settings", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveDest", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveComp", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchivePar", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveSplit", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {text => "CfgEdit_Title_Include_Exclude", visible => sub { return $_[0]->{XferMethod} ne "archive"; } }, {name => "BackupFilesOnly", visible => sub { return $_[0]->{XferMethod} ne "archive"; } }, {name => "BackupFilesExclude", visible => sub { return $_[0]->{XferMethod} ne "archive"; } }, {text => "CfgEdit_Title_Smb_Paths_Commands", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbClientPath", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbClientFullCmd", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbClientIncrCmd", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbClientRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {text => "CfgEdit_Title_Tar_Paths_Commands", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarClientPath", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarClientCmd", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarFullArgs", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarIncrArgs", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarClientRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {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 => "RsyncClientPath", visible => sub { return $_[0]->{XferMethod} eq "rsync"; } }, {name => "RsyncClientCmd", visible => sub { return $_[0]->{XferMethod} eq "rsync"; } }, {name => "RsyncClientRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "rsync"; } }, {name => "RsyncdClientPort", visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } }, {name => "RsyncArgs", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, {name => "RsyncRestoreArgs", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, {text => "CfgEdit_Title_Archive_Paths_Commands", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveClientCmd", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, ], }, schedule => { text => "CfgEdit_Title_Schedule", param => [ {text => "CfgEdit_Title_Full_Backups"}, {name => "FullPeriod"}, {name => "FullKeepCnt"}, {name => "FullKeepCntMin"}, {name => "FullAgeMax"}, {text => "CfgEdit_Title_Incremental_Backups"}, {name => "IncrPeriod"}, {name => "IncrKeepCnt"}, {name => "IncrKeepCntMin"}, {name => "IncrAgeMax"}, {name => "IncrLevels"}, {name => "IncrFill"}, {text => "CfgEdit_Title_Blackouts"}, {name => "BackupsDisable"}, {name => "BlackoutBadPingLimit"}, {name => "BlackoutGoodCnt"}, {name => "BlackoutPeriods"}, {text => "CfgEdit_Title_Other"}, {name => "PartialAgeMax"}, {name => "RestoreInfoKeepCnt"}, {name => "ArchiveInfoKeepCnt"}, {name => "BackupZeroFilesIsFatal"}, ], }, backup => { text => "CfgEdit_Title_Backup_Settings", param => [ {text => "CfgEdit_Title_Client_Lookup"}, {name => "ClientNameAlias"}, {name => "NmbLookupCmd"}, {name => "NmbLookupFindHostCmd"}, {name => "FixedIPNetBiosNameCheck"}, {name => "PingCmd"}, {name => "PingMaxMsec"}, {text => "CfgEdit_Title_Other"}, {name => "ClientTimeout"}, {name => "MaxOldPerPCLogFiles"}, {name => "CompressLevel"}, {text => "CfgEdit_Title_User_Commands"}, {name => "DumpPreUserCmd"}, {name => "DumpPostUserCmd"}, {name => "DumpPreShareCmd"}, {name => "DumpPostShareCmd"}, {name => "RestorePreUserCmd"}, {name => "RestorePostUserCmd"}, {name => "ArchivePreUserCmd"}, {name => "ArchivePostUserCmd"}, {name => "UserCmdCheckStatus"}, ], }, hosts => { text => "CfgEdit_Title_Hosts", param => [ {text => "CfgEdit_Title_Hosts"}, {name => "Hosts", comment => "CfgEdit_Hosts_Comment"}, ], },);sub action{ my $pc_dir = "$TopDir/pc"; my($content, $contentHidden, $newConf, $override, $mainConf, $hostConf); my $errors = {}; my $host = $In{host}; my $menu = $In{menu} || "server"; my $hosts_path = $Hosts; my $config_path = $host eq "" ? "$TopDir/conf/config.pl" : "$TopDir/pc/$host/config.pl"; my $Privileged = CheckPermission($host) && ($PrivAdmin || $Conf{CgiUserConfigEditEnable}); my $userHost = 1 if ( defined($host) ); my $debugText; if ( !$Privileged ) { ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_edit_config_files}}")); } if ( defined($In{menu}) || $In{saveAction} eq "Save" ) { $errors = errorCheck(); if ( %$errors ) { # # If there are errors, then go back to the same menu # $In{saveAction} = ""; #$In{newMenu} = ""; } if ( (my $var = $In{overrideUncheck}) ne "" ) { # # 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) ) { 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, $override) = inputParse($bpc, $userHost); $override = undef if ( $host eq "" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -