2 // backup.php - allows admin to edit all configuration variables for scheduled backups
4 require_once("../config.php");
5 require_once("../backup/lib.php");
7 optional_variable($courseid);
12 error("Only an admin can use this page");
15 if (!$site = get_site()) {
16 error("Site isn't defined!");
20 $backuploglaststatus = get_string("backuploglaststatus");
21 $backuplogdetailed = get_string("backuplogdetailed");
22 $stradmin = get_string("administration");
23 $strconfiguration = get_string("configuration");
24 $strbackup = get_string("backup");
25 $strbackupdetails = get_string("backupdetails");
26 $strlogs = get_string("logs");
27 $strftimedatetime = get_string("strftimerecent");
28 $strftimetime = get_string("strftimetime").":%S";
29 $strerror = get_string("error");
30 $strok = get_string("ok");
31 $strcourse = get_string("course");
32 $strtimetaken = get_string("timetaken","quiz");
33 $strstatus = get_string("status");
34 $strnext = get_string("next");
36 //Decide when to show last execution logs or detailed logs
39 print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname
,
40 "<a href=\"../admin/index.php\">$stradmin</a> -> ".
41 "<a href=\"../admin/configure.php\">$strconfiguration</a> -> ".
42 "<a href=\"../admin/backup.php\">$strbackup</a> -> ".
45 print_heading($backuploglaststatus);
46 print_simple_box_start("center", "", "$THEME->cellheading");
47 //Now, get every record from backup_courses
48 $courses = get_records("backup_courses");
51 notify("No logs found!");
53 echo "<table border=0 align=center cellpadding=3 cellspacing=3>";
56 echo "<td nowrap align=center><font size=3>$strcourse</font></td>";
57 echo "<td nowrap align=center colspan=3><font size=3>$strtimetaken</font></td>";
58 echo "<td nowrap align=center><font size=3>$strstatus</font></td>";
59 echo "<td nowrap align=center><font size=3>$strnext</font></td>";
60 foreach ($courses as $course) {
61 //Get the course shortname
62 $coursename = get_field ("course","fullname","id",$course->courseid
);
65 echo "<td nowrap><font size=2><a href=\"log.php?courseid=$course->courseid\">".$coursename."</a></td>";
66 echo "<td nowrap><font size=2>".userdate($course->laststarttime
,$strftimedatetime)."</td>";
67 echo "<td nowrap><font size=2> - </td>";
68 echo "<td nowrap><font size=2>".userdate($course->lastendtime
,$strftimedatetime)."</td>";
69 if (!$course->laststatus
) {
70 echo "<td nowrap align=center><font size=2 color=red>".$strerror."</td>";
72 echo "<td nowrap align=center><font size=2 color=green>".$strok."</td>";
74 echo "<td nowrap><font size=2>".userdate($course->nextstarttime
,$strftimedatetime)."</td>";
80 print_simple_box_end();
83 print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname
,
84 "<a href=\"../admin/index.php\">$stradmin</a> -> ".
85 "<a href=\"../admin/configure.php\">$strconfiguration</a> -> ".
86 "<a href=\"../admin/backup.php\">$strbackup</a> -> ".
87 "<a href=\"log.php\">$strlogs</a> -> ".
90 print_heading($backuplogdetailed);
92 $coursename = get_field("course","fullname","id","$courseid");
93 print_heading("$strcourse: $coursename");
95 print_simple_box_start("center", "", "$THEME->cellheading");
97 //First, me get all the distinct backups for that course in backup_log
98 $executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime
99 FROM {$CFG->prefix}backup_log
100 WHERE courseid = '$courseid'
101 ORDER BY laststarttime DESC");
103 //Iterate over backup executions
105 notify("No logs found!");
107 echo "<table border=0 align=center cellpadding=3 cellspacing=3>";
108 foreach($executions as $execution) {
110 echo "<td nowrap align=center colspan=3>";
111 print_simple_box("<center>".userdate($execution->laststarttime
)."</center>", "center");
114 $logs = get_records_sql("SELECT *
115 FROM {$CFG->prefix}backup_log
116 WHERE courseid = '$courseid' AND
117 laststarttime = '$execution->laststarttime'
120 foreach ($logs as $log) {
122 echo "<td nowrap><font size=2>".userdate($log->time
,$strftimetime)."</font></td>";
123 $log->info
= str_replace("- ERROR!!","- <font color=red>ERROR!!</font>",$log->info
);
124 $log->info
= str_replace("- OK","- <font color=green>OK</font>",$log->info
);
125 echo "<td nowrap><font size=2>".str_replace(" "," ",$log->info
)."</font></td>";
132 print_simple_box_end();