/
recieveXML.php
68 lines (55 loc) · 1.84 KB
/
recieveXML.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<title>Document save message</title>
</head>
<body>
<p>
<?php
/**
* This code is copyright to EuroMotor AutoTrain LLP and is licenced under the GNU GPLv3 Licence
**/
require_once("../../config.php");
require_once("lib.php");
require_once("$CFG->libdir/rsslib.php");
$l = required_param('xmlid',PARAM_INT);
global $DB;
if (! $autoview = $DB->get_record("autoview", array("id"=>$l)))
error("Course module is incorrect");
if (! $course = $DB->get_record("course", array("id"=>$autoview->course)))
error("Course is misconfigured");
if (! $cm = get_coursemodule_from_instance("autoview", $autoview->id, $course->id))
error("Course Module ID was incorrect");
require_login($course->id);
$context = autoview_get_context_instance($cm->id);
if (has_capability('mod/autoview:canedit', $context))
{
$xmldata=optional_param('xmldata', false, PARAM_RAW);
if ($xmldata!=false)
$xmldata=base64_decode($xmldata);
$subdata=optional_param('subdata', false, PARAM_RAW);
if ($subdata!=false)
$subdata=base64_decode($subdata);
$subtitlefile=optional_param('subtitlefile','', PARAM_PATH);
if (strlen($subtitlefile)>0 && $subdata!=false)
{echo $subdata;
$file=$CFG->dataroot.'/'.$course->id.'/'.$subtitlefile;
$fh = fopen($file, 'w') or die(get_string("xmlsavefailed", "autoview"));
fwrite($fh, $subdata);
fclose($fh);
}
if ($xmldata!=false)
{echo $xmldata;
$file=$CFG->dataroot.'/'.$course->id.'/'.$autoview->configfile;
$fh = fopen($file, 'w') or die(get_string("xmlsavefailed", "autoview"));
fwrite($fh, $xmldata);
fclose($fh);
}
echo get_string("pres_saved", "autoview");
}
else
echo get_string("no_edit_permission", "autoview");
?>
</p>
</body>
</html>