2 // backup.php - allows admin to edit all configuration variables for scheduled backups
4 require_once("../config.php");
5 require_once("../backup/lib.php");
10 error("Only an admin can use this page");
13 if (!$site = get_site()) {
14 error("Site isn't defined!");
17 //Initialise error variables
19 $sche_destination_error = "";
21 /// If data submitted, then process and store.
23 if ($config = data_submitted()) {
25 //First of all we check that everything is correct
26 //Check for trailing slash and backslash in backup_sche_destination
27 if (!empty($backup_sche_destination) and
28 (substr($backup_sche_destination,-1) == "/" or substr($backup_sche_destination,-1) == "\\")) {
30 $sche_destination_error = get_string("pathslasherror");
31 //Now check that backup_sche_destination dir exists
32 } else if (!empty($backup_sche_destination) and
33 !is_dir($backup_sche_destination)) {
35 $sche_destination_error = get_string("pathnotexists");
38 //We need to do some weekdays conversions prior to continue
41 $a_config = (array)$config;
43 $tocheck = "dayofweek_".$i;
44 if (isset($a_config[$tocheck])) {
49 unset($a_config[$tocheck]);
52 $a_config['backup_sche_weekdays'] = $temp;
53 $config = (object)$a_config;
54 //weekdays conversions done. Continue
57 foreach ($config as $name => $value) {
58 backup_set_config($name, $value);
61 redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
66 /// Otherwise print the form.
68 $stradmin = get_string("administration");
69 $strconfiguration = get_string("configuration");
70 $strbackup = get_string("backup");
72 print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname
,
73 "<a href=\"index.php\">$stradmin</a> -> ".
74 "<a href=\"configure.php\">$strconfiguration</a> -> ".
77 echo "<p align=right><a href=\"../backup/log.php\">".get_string("logs")."</a></p>";
79 print_heading($strbackup);
81 print_simple_box("<center>".get_string("adminhelpbackup")."</center>", "center", "50%");
84 print_simple_box_start("center", "", "$THEME->cellheading");
85 include("$CFG->dirroot/backup/config.html");
86 print_simple_box_end();