From eb74cfd05e4ecdf0712e5667b0999c885a275b98 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 26 Jan 2004 23:24:12 +0000 Subject: [PATCH] Now the destination directory in scheduled bakups have some checks: - Trailing slashes. - Trailing backslashes. - Exists. --- admin/backup.php | 25 ++++++++++++++++++++++--- backup/config.html | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/admin/backup.php b/admin/backup.php index bca671524e..fd6b99f591 100644 --- a/admin/backup.php +++ b/admin/backup.php @@ -14,10 +14,27 @@ error("Site isn't defined!"); } + //Initialise error variables + $error = false; + $sche_destination_error = ""; -/// If data submitted, then process and store. + /// If data submitted, then process and store. if ($config = data_submitted()) { + + //First of all we check that everything is correct + //Check for trailing slash and backslash in backup_sche_destination + if (!empty($backup_sche_destination) and + (substr($backup_sche_destination,-1) == "/" or substr($backup_sche_destination,-1) == "\\")) { + $error = true; + $sche_destination_error = get_string("pathslasherror"); + //Now check that backup_sche_destination dir exists + } else if (!empty($backup_sche_destination) and + !is_dir($backup_sche_destination)) { + $error = true; + $sche_destination_error = get_string("pathnotexists"); + } + //We need to do some weekdays conversions prior to continue $i = 0; $temp = ""; @@ -40,8 +57,10 @@ foreach ($config as $name => $value) { backup_set_config($name, $value); } - redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1); - exit; + if (!$error) { + redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1); + exit; + } } /// Otherwise print the form. diff --git a/backup/config.html b/backup/config.html index 09e2e74c75..208779ae46 100644 --- a/backup/config.html +++ b/backup/config.html @@ -196,7 +196,7 @@ - :
+ :
"; } ?> -- 2.39.5