diff --git a/actions/admin/settings/110.accounts.php b/actions/admin/settings/110.accounts.php
index eb2a24a6..95df194e 100644
--- a/actions/admin/settings/110.accounts.php
+++ b/actions/admin/settings/110.accounts.php
@@ -186,6 +186,15 @@ return array(
)
),
),
+ 'system_backupenabled' => array(
+ 'label' => $lng['serversettings']['backupenabled'],
+ 'settinggroup' => 'system',
+ 'varname' => 'backupenabled',
+ 'type' => 'bool',
+ 'default' => false,
+ 'cronmodule' => 'froxlor/backup',
+ 'save_method' => 'storeSettingField'
+ ),
),
),
);
diff --git a/customer_extras.php b/customer_extras.php
index 96907cb3..9ed48994 100644
--- a/customer_extras.php
+++ b/customer_extras.php
@@ -519,65 +519,73 @@ if ($page == 'overview') {
}
}
} elseif ($page == 'backup') {
- if ($action == '') {
- $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup");
- if (isset($_POST['send']) && $_POST['send'] == 'send') {
+ if (Settings::Get('system.backupenabled') == 1)
+ {
+ if ($action == '') {
+ $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup");
- if (! $_POST['path']) {
- standard_error('invalidpath');
- }
+ if (isset($_POST['send']) && $_POST['send'] == 'send') {
- $path = makeCorrectDir(validate($_POST['path'], 'path'));
- $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
-
- $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;
-
- if ($backup_dbs != '1') {
- $backup_dbs = '0';
- }
-
- if ($backup_mail != '1') {
- $backup_mail = '0';
- }
-
- if ($backup_web != '1') {
- $backup_web = '0';
- }
-
- $task_data = array(
- 'customerid' => $userinfo['customerid'],
- 'uid' => $userinfo['guid'],
- 'gid' => $userinfo['guid'],
- 'loginname' => $userinfo['loginname'],
- 'destdir' => $path,
- 'backup_dbs' => $backup_dbs,
- 'backup_mail' => $backup_mail,
- 'backup_web' => $backup_web
- );
- inserttask('20', $task_data);
-
- standard_success('backupscheduled');
- } else {
-
- // check whether there is a backup-job for this customer
- $sel_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_TASKS."` WHERE `type` = '20'");
- Database::pexecute($sel_stmt);
- while ($entry = $sel_stmt->fetch())
- {
- $data = unserialize($entry['data']);
- if ($data['customerid'] == $userinfo['customerid']) {
- standard_error('customerhasongoingbackupjob');
+ if (! $_POST['path']) {
+ standard_error('invalidpath');
}
+
+ $path = makeCorrectDir(validate($_POST['path'], 'path'));
+ $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
+
+ $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;
+
+ if ($backup_dbs != '1') {
+ $backup_dbs = '0';
+ }
+
+ if ($backup_mail != '1') {
+ $backup_mail = '0';
+ }
+
+ if ($backup_web != '1') {
+ $backup_web = '0';
+ }
+
+ $task_data = array(
+ 'customerid' => $userinfo['customerid'],
+ 'uid' => $userinfo['guid'],
+ 'gid' => $userinfo['guid'],
+ 'loginname' => $userinfo['loginname'],
+ 'destdir' => $path,
+ 'backup_dbs' => $backup_dbs,
+ 'backup_mail' => $backup_mail,
+ 'backup_web' => $backup_web
+ );
+ inserttask('20', $task_data);
+
+ standard_success('backupscheduled');
+ } else {
+
+ // check whether there is a backup-job for this customer
+ $sel_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_TASKS."` WHERE `type` = '20'");
+ Database::pexecute($sel_stmt);
+ while ($entry = $sel_stmt->fetch())
+ {
+ $data = unserialize($entry['data']);
+ if ($data['customerid'] == $userinfo['customerid']) {
+ standard_error('customerhasongoingbackupjob');
+ }
+ }
+ $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
+ $backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
+ $backup_form = htmlform::genHTMLForm($backup_data);
+ $title = $backup_data['backup']['title'];
+ $image = $backup_data['backup']['image'];
+ eval("echo \"" . getTemplate("extras/backup") . "\";");
}
- $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
- $backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
- $backup_form = htmlform::genHTMLForm($backup_data);
- $title = $backup_data['backup']['title'];
- $image = $backup_data['backup']['image'];
- eval("echo \"" . getTemplate("extras/backup") . "\";");
}
}
-}
\ No newline at end of file
+ else
+ {
+ standard_error('backupfunctionnotenabled');
+ }
+}
diff --git a/install/froxlor.sql b/install/froxlor.sql
index 5bece437..178b9135 100644
--- a/install/froxlor.sql
+++ b/install/froxlor.sql
@@ -525,6 +525,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('system', 'letsencryptkeysize', '4096'),
('system', 'letsencryptreuseold', 0),
('system', 'leenabled', '0'),
+ ('system', 'backupenabled', '0'),
('panel', 'decimal_places', '4'),
('panel', 'adminmail', 'admin@SERVERNAME'),
('panel', 'phpmyadmin_url', ''),
diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php
index c34c0dc3..5a096f90 100644
--- a/install/updates/froxlor/0.9/update_0.9.inc.php
+++ b/install/updates/froxlor/0.9/update_0.9.inc.php
@@ -3295,7 +3295,9 @@ if (isFroxlorVersion('0.9.35')) {
if (isFroxlorVersion('0.9.35.1') && isDatabaseVersion('201603150')) {
- showUpdateStep("Adding new backup-cron entry");
+ showUpdateStep("Adding new backup settings and cron");
+ $enable_backup = isset($_POST['enable_backup']) ? (int) $_POST['enable_backup'] : "0";
+ Settings::AddNew("system.backupenabled", $enable_backup);
$stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_CRONRUNS . "` SET
`module` = 'froxlor/backup',
@@ -3303,9 +3305,9 @@ if (isFroxlorVersion('0.9.35.1') && isDatabaseVersion('201603150')) {
`interval` = '1 DAY',
`desc_lng_key` = 'cron_backup',
`lastrun` = 0,
- `isactive` = 0"
+ `isactive` = :isactive"
);
- Database::pexecute($stmt);
+ Database::pexecute($stmt, array('isactive' => $enable_backup));
lastStepStatus(0);
updateToDbVersion('201604270');
diff --git a/install/updates/preconfig/0.9/preconfig_0.9.inc.php b/install/updates/preconfig/0.9/preconfig_0.9.inc.php
index 28613aba..0c9d6559 100644
--- a/install/updates/preconfig/0.9/preconfig_0.9.inc.php
+++ b/install/updates/preconfig/0.9/preconfig_0.9.inc.php
@@ -708,4 +708,12 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version, $c
$question.= makeyesno('enable_letsencrypt', '1', '0', '1').'
';
eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
}
+
+ if (versionInUpdate($current_db_version, '201604270')) {
+ $has_preconfig = true;
+ $description = 'You can chose whether you want to enable or disable our backup function.
';
+ $question = 'Do you want to enable Backup? (default: no): ';
+ $question.= makeyesno('enable_backup', '1', '0', '0').'
';
+ eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
+ }
}
diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php
index cb6f0401..2a989942 100644
--- a/lib/navigation/00.froxlor.main.php
+++ b/lib/navigation/00.froxlor.main.php
@@ -132,6 +132,7 @@ return array (
array (
'url' => 'customer_extras.php?page=backup',
'label' => $lng['menue']['extras']['backup'],
+ 'show_element' => ( Settings::Get('system.backupenabled') == true ),
),
),
),
diff --git a/lng/english.lng.php b/lng/english.lng.php
index 8e0d72f0..f35d5437 100644
--- a/lng/english.lng.php
+++ b/lng/english.lng.php
@@ -1983,3 +1983,6 @@ $lng['extras']['backup_dbs'] = 'Backup databases';
$lng['error']['customerhasongoingbackupjob'] = 'There is already a backup job waiting to be processed, please be patient.';
$lng['success']['backupscheduled'] = 'Your backup job has been scheduled. Please wait for it to be processed';
$lng['crondesc']['cron_backup'] = 'Process backup jobs';
+$lng['error']['backupfunctionnotenabled'] = 'The backup function is not enabled';
+$lng['serversettings']['backupenabled']['title'] = "Enable backup for customers";
+$lng['serversettings']['backupenabled']['description'] = "If activated, the customer will be able to schedule backup jobs (cron-backup) which generates an archive within his docroot (subdirectory chosable by customer)";
diff --git a/lng/german.lng.php b/lng/german.lng.php
index 6fe024b2..76de5ec4 100644
--- a/lng/german.lng.php
+++ b/lng/german.lng.php
@@ -1636,3 +1636,6 @@ $lng['extras']['backup_dbs'] = 'Datenbanken sichern';
$lng['error']['customerhasongoingbackupjob'] = 'Es gibt noch einen austehenden Backup-Job. Bitte haben Sie etwas Geduld.';
$lng['success']['backupscheduled'] = 'Ihre Sicherung wurde erfolgreich geplant. Bitte warten Sie nun, bis diese abgearbeitet wurde.';
$lng['crondesc']['cron_backup'] = 'Ausstehende Sicherungen erstellen';
+$lng['error']['backupfunctionnotenabled'] = 'Die Sicherungs-Funktion is nicht aktiviert';
+$lng['serversettings']['backupenabled']['title'] = "Backup für Kunden aktivieren";
+$lng['serversettings']['backupenabled']['description'] = "Wenn dies aktiviert ist, kann der Kunde Sicherungen planen (cron-backup) welche ein Archiv in sein Heimatverzeichnis ablegt (Unterordner vom Kunden wählbar)";