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 $courseid = optional_param('courseid',0,PARAM_INT
);
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 $strunfinished = get_string("unfinished");
32 $strskipped = get_string("skipped");
33 $strcourse = get_string("course");
34 $strtimetaken = get_string("timetaken","quiz");
35 $strstatus = get_string("status");
36 $strnext = get_string("next");
38 //Decide when to show last execution logs or detailed logs
41 print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname
,
42 "<a href=\"../$CFG->admin/index.php\">$stradmin</a> -> ".
43 "<a href=\"../$CFG->admin/configure.php\">$strconfiguration</a> -> ".
44 "<a href=\"../$CFG->admin/backup.php?sesskey=$USER->sesskey\">$strbackup</a> -> ".
47 print_heading($backuploglaststatus);
48 print_simple_box_start('center');
49 //Now, get every record from backup_courses
50 $courses = get_records("backup_courses");
53 notify("No logs found!");
55 echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
58 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strcourse</font></td>";
59 echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\"><font size=\"3\">$strtimetaken</font></td>";
60 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strstatus</font></td>";
61 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strnext</font></td></tr>";
62 foreach ($courses as $course) {
63 //Get the course shortname
64 $coursename = get_field ("course","fullname","id",$course->courseid
);
67 echo "<td nowrap=\"nowrap\"><font size=\"2\"><a href=\"log.php?courseid=$course->courseid\">".$coursename."</a></font></td>";
68 echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->laststarttime
,$strftimedatetime)."</font></td>";
69 echo "<td nowrap=\"nowrap\"><font size=\"2\"> - </font></td>";
70 echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->lastendtime
,$strftimedatetime)."</font></td>";
71 if ($course->laststatus
== 1) {
72 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strok."</font></td>";
73 } else if ($course->laststatus
== 2) {
74 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strunfinished."</font></td>";
75 } else if ($course->laststatus
== 3) {
76 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strskipped."</font></td>";
78 echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strerror."</font></td>";
80 echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->nextstarttime
,$strftimedatetime)."</font></td>";
86 print_simple_box_end();
89 print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname
,
90 "<a href=\"../$CFG->admin/index.php\">$stradmin</a> -> ".
91 "<a href=\"../$CFG->admin/configure.php\">$strconfiguration</a> -> ".
92 "<a href=\"../$CFG->admin/backup.php?sesskey=$USER->sesskey\">$strbackup</a> -> ".
93 "<a href=\"log.php\">$strlogs</a> -> ".
96 print_heading($backuplogdetailed);
98 $coursename = get_field("course","fullname","id","$courseid");
99 print_heading("$strcourse: $coursename");
101 print_simple_box_start('center');
103 //First, me get all the distinct backups for that course in backup_log
104 $executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime
105 FROM {$CFG->prefix}backup_log
106 WHERE courseid = '$courseid'
107 ORDER BY laststarttime DESC");
109 //Iterate over backup executions
111 notify("No logs found!");
113 echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
114 foreach($executions as $execution) {
116 echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\">";
117 print_simple_box("<center>".userdate($execution->laststarttime
)."</center>", "center");
120 $logs = get_records_sql("SELECT *
121 FROM {$CFG->prefix}backup_log
122 WHERE courseid = '$courseid' AND
123 laststarttime = '$execution->laststarttime'
126 foreach ($logs as $log) {
128 echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($log->time
,$strftimetime)."</font></td>";
129 $log->info
= str_replace("- ERROR!!","- <font color=\"red\">ERROR!!</font>",$log->info
);
130 $log->info
= str_replace("- OK","- <font color=\"green\">OK</font>",$log->info
);
131 echo "<td nowrap=\"nowrap\"><font size=\"2\">".str_replace(" "," ",$log->info
)."</font></td>";
138 print_simple_box_end();