diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html
index 1f721115465..8060138aa1a 100644
--- a/backup/restore_precheck.html
+++ b/backup/restore_precheck.html
@@ -59,8 +59,16 @@
//Now check for the moodle.xml file
if ($status) {
+ $xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml";
echo "
Checking backup file";
- $status = restore_check_moodle_file ($CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml");
+ $status = restore_check_moodle_file ($xml_file);
+ }
+
+ //Now read the info tag (all)
+ if ($status) {
+ echo "Reading info from file";
+ //Reading info from file
+ $info = restore_read_xml_info ($xml_file);
}
//End the main ul
diff --git a/backup/restorelib.php b/backup/restorelib.php
index 96272f6df29..f5433b90566 100644
--- a/backup/restorelib.php
+++ b/backup/restorelib.php
@@ -1,7 +1,7 @@
tree[$this->level] = $tagName;
+ //echo str_repeat(" ",$this->level*2)."<".$tagName.">
\n";
+ $this->level++;
+ }
+
+ function endElement($parser, $tagName) {
+ if (trim($this->content)) {
+ //echo utf8_decode(str_repeat(" ",$this->level*2).$this->content."
\n");
+ }
+ $this->level--;
+ //echo str_repeat(" ",$this->level*2)."</".$tagName.">
\n";
+ $this->tree[$this->level] = "";
+ $this->content = "";
+
+ //Stop parsing if todo = INFO and tagName = INFO
+ //Speed up a lot (avoid parse all)
+ //echo $tagName."
";
+ if (($this->todo == "INFO") and ($tagName == "INFO")) {
+ $this->finished = true;
+ }
+ }
+
+ function characterData($parser, $data) {
+ $this->content .= $data;
+ }
+ }
+
+ //This function executes the MoodleParser
+ function restore_read_xml ($xml_file,$todo,$preferences) {
+
+ $status = true;
+
+ $xml_parser = xml_parser_create();
+ $moodle_parser = new MoodleParser();
+ $moodle_parser->todo = $todo;
+ $moodle_parser->preferences = $preferences;
+ xml_set_object($xml_parser,&$moodle_parser);
+ xml_set_element_handler($xml_parser, "startElement", "endElement");
+ xml_set_character_data_handler($xml_parser, "characterData");
+ $fp = fopen($xml_file,"r")
+ or $status = false;
+ if ($status) {
+ while ($data = fread($fp, 4096) and !$moodle_parser->finished)
+ xml_parse($xml_parser, $data, feof($fp))
+ or die(sprintf("XML error: %s at line %d",
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+ fclose($fp);
+ }
+ xml_parser_free($xml_parser);
+
+ if ($Status) {
+ return $info;
+ } else {
+ return $status;
+ }
+ }
?>