]> git.mjollnir.org Git - moodle.git/commitdiff
Now the destination directory in scheduled bakups have some checks:
authorstronk7 <stronk7>
Mon, 26 Jan 2004 23:24:12 +0000 (23:24 +0000)
committerstronk7 <stronk7>
Mon, 26 Jan 2004 23:24:12 +0000 (23:24 +0000)
   - Trailing slashes.
   - Trailing backslashes.
   - Exists.

admin/backup.php
backup/config.html

index bca671524e55c6258741f6137bc5a42387462f66..fd6b99f5919cb63147c0719f7a5c82a9757960b8 100644 (file)
         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 = "";
         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.
index 09e2e74c7525bf5d42dba5eda9a637251f54c5df..208779ae46ca065f1334caa33fe6cf1c1ec45a49 100644 (file)
 </tr>
 <tr valign=top>
     <td colspan = 3 align=center>
-        <?php print_string("saveto") ?>: <input name="backup_sche_destination" type="text" size="40" value="<?php p($backup_config->backup_sche_destination) ?>"><br><?php print_string("backupsavetohelp") ?>
+        <?php print_string("saveto") ?>: <input name="backup_sche_destination" type="text" size="40" value="<?php p($backup_config->backup_sche_destination) ?>"><br><?php if (!empty($sche_destination_error)) { formerr($sche_destination_error); echo "<br>"; } ?><?php print_string("backupsavetohelp") ?>
     </td>
 </tr>
 <tr>