mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
do NOT allow to change backup_files config if backup is called outside of setup, as it can have a huge impact on the server
This commit is contained in:
parent
d46605ecf7
commit
3afe73c701
@ -299,47 +299,29 @@ class db_backup
|
||||
/**
|
||||
* Save the housekeeping configuration in the database and update the local variables.
|
||||
*
|
||||
* @param mincount Minimum number of backups to keep.
|
||||
* @param int $mincount Minimum number of backups to keep.
|
||||
* @param boolean $backup_files include files in backup or not, default dont change!
|
||||
*/
|
||||
function saveConfig($config_values)
|
||||
function saveConfig($minCount,$backupFiles=null)
|
||||
{
|
||||
if (!is_array($config_values))
|
||||
config::save_value('backup_mincount',$this->backup_mincount=(int)$minCount,'phpgwapi');
|
||||
|
||||
if (!is_null($backupFiles))
|
||||
{
|
||||
error_log(__METHOD__." unable to save backup config values, wrong type of parameter passed.");
|
||||
return false;
|
||||
config::save_value('backup_files',$this->backup_files=(boolean)$backupFiles,'phpgwapi');
|
||||
}
|
||||
//_debug_array($config_values);
|
||||
$minCount = $config_values['backup_mincount'];
|
||||
$backupFiles = (int)$config_values['backup_files'];
|
||||
/* minCount */
|
||||
$this->db->insert(
|
||||
self::TABLE,
|
||||
array(
|
||||
'config_value' => $minCount,
|
||||
),
|
||||
array(
|
||||
'config_app' => 'phpgwapi',
|
||||
'config_name' => 'backup_mincount',
|
||||
),
|
||||
__LINE__,
|
||||
__FILE__);
|
||||
/* backup files flag */
|
||||
$this->db->insert(self::TABLE,array('config_value' => $backupFiles),array('config_app' => 'phpgwapi','config_name' => 'backup_files'),__LINE__,__FILE__);
|
||||
$this->backup_mincount = $minCount;
|
||||
$this->backup_files = (bool)$backupFiles;
|
||||
// Update session cache
|
||||
if (is_a($GLOBALS['egw'],'egw')) $GLOBALS['egw']->invalidate_session_cache();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Certain config settings NOT to restore (because they break a working system)
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $system_config = array(
|
||||
'files_dir',
|
||||
'temp_dir',
|
||||
'backup_dir',
|
||||
'backup_files',
|
||||
'webserver_url',
|
||||
'aspell_path',
|
||||
'hostname',
|
||||
@ -364,9 +346,9 @@ class db_backup
|
||||
{
|
||||
@set_time_limit(0);
|
||||
ini_set('auto_detect_line_endings',true);
|
||||
|
||||
|
||||
$convert_to_system_charset = true; // enforce now utf-8 as system charset restores of old backups
|
||||
|
||||
|
||||
if ($protect_system_config)
|
||||
{
|
||||
$system_config = array();
|
||||
@ -756,7 +738,7 @@ class db_backup
|
||||
fwrite($f,implode(',',$row)."\n");
|
||||
}
|
||||
}
|
||||
if(!$zippresent) // save without files
|
||||
if(!$zippresent) // save without files
|
||||
{
|
||||
if ($this->backup_files)
|
||||
{
|
||||
|
@ -27,6 +27,7 @@ if (!is_object(@$GLOBALS['egw'])) // called from outside eGW ==> setup
|
||||
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$self = 'db_backup.php';
|
||||
$is_setup = true;
|
||||
}
|
||||
$db_backup = new db_backup();
|
||||
$asyncservice = new asyncservice();
|
||||
@ -77,19 +78,15 @@ if ($_POST['save_backup_settings'])
|
||||
$matches = array();
|
||||
preg_match('/^[1-9][0-9]*$/', $_POST['backup_mincount'], $matches);
|
||||
$minCount = $matches[0];
|
||||
$filesBackup =false;
|
||||
if ($_POST['backup_files']==='backup_files') $filesBackup = true;
|
||||
$filesBackup = $_POST['backup_files'] === 'backup_files';
|
||||
if (empty($minCount))
|
||||
{
|
||||
$minCount = 0;
|
||||
$setup_tpl->set_var('error_msg',htmlspecialchars(lang("'%1' must be integer", lang("backup min count"))));
|
||||
}
|
||||
$configValues = array(
|
||||
'backup_mincount'=>$minCount,
|
||||
'backup_files' =>$filesBackup,
|
||||
);
|
||||
$db_backup->saveConfig($configValues);
|
||||
if (is_int($minCount) && $minCount>0)
|
||||
$db_backup->saveConfig($minCount,$is_setup ? (boolean)$filesBackup : null);
|
||||
|
||||
if (is_int($minCount) && $minCount > 0)
|
||||
{
|
||||
$cleaned_files = array();
|
||||
/* Remove old backups. */
|
||||
@ -128,7 +125,10 @@ $setup_tpl->set_var('backup_now_button','<input type="submit" name="backup" titl
|
||||
$setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '.
|
||||
'<input type="submit" name="upload" value="'.htmlspecialchars(lang('upload backup')).'" title="'.htmlspecialchars(lang("uploads a backup to the backup-dir, from where you can restore it")).'" />');
|
||||
$setup_tpl->set_var('backup_mincount','<input type="text" name="backup_mincount" value="'.$db_backup->backup_mincount.'" size="3" maxlength="3"/>');
|
||||
$setup_tpl->set_var('backup_files','<input type="checkbox" name="backup_files" value="backup_files"'.((bool)$db_backup->backup_files ? 'checked':'').'/>');
|
||||
$setup_tpl->set_var('backup_files','<input type="checkbox" name="backup_files" value="backup_files"'.
|
||||
($db_backup->backup_files ? ' checked="true"':'').
|
||||
// do NOT allow to change "backup files" outside of setup
|
||||
($is_setup ? '' : ' disabled="true" title="'.htmlspecialchars(lang('Can only be change via Setup!')).'"').'/>');
|
||||
$setup_tpl->set_var('backup_save_settings','<input type="submit" name="save_backup_settings" value="'.htmlspecialchars(lang('save')).'" />');
|
||||
|
||||
if ($_POST['upload'] && is_array($_FILES['uploaded']) && !$_FILES['uploaded']['error'] &&
|
||||
|
Loading…
Reference in New Issue
Block a user