From aa6f3d33ebf4a2f56d4fd9f0f91a131c74aedac5 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 11 Oct 2018 14:52:45 +0200 Subject: [PATCH] clearify description and enhance validation for path-field in backup-job-planning Signed-off-by: Michael Kaufmann --- customer_extras.php | 5 +++++ lib/formfields/customer/extras/formfield.backup.php | 4 ++-- lng/english.lng.php | 3 +++ lng/german.lng.php | 3 +++ scripts/jobs/cron_backup.php | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/customer_extras.php b/customer_extras.php index 5ef3cb61..93fdefb6 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -579,6 +579,11 @@ if ($page == 'overview') { $path = makeCorrectDir(validate($_POST['path'], 'path')); $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path); + // path cannot be the customers docroot + if ($path == makeCorrectDir($userinfo['documentroot'])) { + standar_error('backupfoldercannotbedocroot'); + } + $backup_dbs = isset($_POST['backup_dbs']) ? intval($_POST['backup_dbs']) : 0; $backup_mail = isset($_POST['backup_mail']) ? intval($_POST['backup_mail']) : 0; $backup_web = isset($_POST['backup_web']) ? intval($_POST['backup_web']) : 0; diff --git a/lib/formfields/customer/extras/formfield.backup.php b/lib/formfields/customer/extras/formfield.backup.php index 4a808ec0..1cc11b87 100644 --- a/lib/formfields/customer/extras/formfield.backup.php +++ b/lib/formfields/customer/extras/formfield.backup.php @@ -24,8 +24,8 @@ return array( 'image' => 'icons/backup_big.png', 'fields' => array( 'path' => array( - 'label' => $lng['panel']['path'], - 'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '
'.$pathSelect['value'] : ''), + 'label' => $lng['panel']['backuppath']['title'], + 'desc' => $lng['panel']['backuppath']['description'].'
'.(Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '
'.$pathSelect['value'] : ''), 'type' => $pathSelect['type'], 'select_var' => $pathSelect['value'], 'value' => $pathSelect['value'] diff --git a/lng/english.lng.php b/lng/english.lng.php index 9af2071e..fab04ddb 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -229,6 +229,7 @@ $lng['error']['destinationalreadyexistasmail'] = 'The forwarder to %s already ex $lng['error']['destinationalreadyexist'] = 'You have already defined a forwarder to %s .'; $lng['error']['destinationiswrong'] = 'The forwarder %s contains invalid character(s) or is incomplete.'; $lng['error']['ticketnotaccessible'] = 'You cannot access this ticket.'; +$lng['error']['backupfoldercannotbedocroot'] = 'The folder for backups cannot be your homedir, please chose a folder within your homedir, e.g. /backups'; /** * Questions @@ -2127,3 +2128,5 @@ $lng['admin']['notryfiles']['title'] = 'No autogenerated try_files'; $lng['admin']['notryfiles']['description'] = 'Say yes here if you want to specify a custom try_files directive in specialsettings (needed for some wordpress plugins for example).'; $lng['serversettings']['phpfpm_settings']['override_fpmconfig'] = 'Override FPM-daemon settings (pm, max_children, etc.)'; $lng['serversettings']['phpfpm_settings']['override_fpmconfig_addinfo'] = '
Only used if "Override FPM-daemon settings" is set to "Yes"'; +$lng['panel']['backuppath']['title'] = 'Destination path for the backup'; +$lng['panel']['backuppath']['description'] = 'This is the path where the backups will be stored. If backup of web-data is selected, all files from the homedir are stored excluding the backup-folder specified here.'; diff --git a/lng/german.lng.php b/lng/german.lng.php index f5da555f..ac88763a 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -227,6 +227,7 @@ $lng['error']['destinationalreadyexistasmail'] = 'Die Weiterleitung zu "%s" exis $lng['error']['destinationalreadyexist'] = 'Es existiert bereits eine Weiterleitung nach "%s".'; $lng['error']['destinationiswrong'] = 'Die Weiterleitungsadresse "%s" enthält ungültige Zeichen oder ist nicht vollständig.'; $lng['error']['ticketnotaccessible'] = 'Sie können sich das Ticket nicht ansehen.'; +$lng['error']['backupfoldercannotbedocroot'] = 'Der Ordner für Backups darf nicht das Heimatverzeichnis sein, wähle einen Ordner unterhalb des Heimatverzeichnisses, z.B. /backups'; /** * Questions @@ -1777,3 +1778,5 @@ $lng['admin']['notryfiles']['title'] = 'Keine generierte try_files Anweisung'; $lng['admin']['notryfiles']['description'] = 'Wähle "Ja", wenn eine eigene try_files Direktive in den "eigenen Vhost Einstellungen" angegeben werden soll (z.B. nötig für manche Wordpress Plugins).'; $lng['serversettings']['phpfpm_settings']['override_fpmconfig'] = 'Überschreibe FPM-Daemon Einstellungen (pm, max_children, etc.)'; $lng['serversettings']['phpfpm_settings']['override_fpmconfig_addinfo'] = '
Nur verwendet wenn "Überschreibe FPM-Daemon Einstellungen" auf "Ja" gestellt ist'; +$lng['panel']['backuppath']['title'] = 'Pfad zur Ablage der Backups'; +$lng['panel']['backuppath']['description'] = 'In diesem Ordner werden die Backups abgelegt. Wenn das Sichern von Web-Daten aktiviert ist, werden alle Dateien aus dem Heimatverzeichnis gesichert, exklusive des hier angegebenen Backup-Ordners.'; diff --git a/scripts/jobs/cron_backup.php b/scripts/jobs/cron_backup.php index 131a2004..87f866fa 100644 --- a/scripts/jobs/cron_backup.php +++ b/scripts/jobs/cron_backup.php @@ -91,6 +91,7 @@ foreach ($all_jobs as $row) { $row['data']['destdir'] = makeCorrectDir($row['data']['destdir']); $customerdocroot = makeCorrectDir(Settings::Get('system.documentroot_prefix').'/'.$row['data']['loginname'].'/'); + // create folder if not exists if (!file_exists($row['data']['destdir']) && $row['data']['destdir'] != '/' && $row['data']['destdir'] != Settings::Get('system.documentroot_prefix')