-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploadmp3.php.old
55 lines (35 loc) · 1.77 KB
/
uploadmp3.php.old
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
<?php // $Id: uploadmp3.php,v 1.2 2012/03/10 22:00:00 Igor Nikulin Exp $
require_once '../../config.php';
require_once 'lib.php';
$id = optional_param('p1', 0, PARAM_INT);
$userid = optional_param('p2', 0, PARAM_INT);
$fid = optional_param('p3', 0, PARAM_INT);
$filename = optional_param('p4', NULL, PARAM_TEXT);
$requestid = optional_param('requestid', NULL, PARAM_INT);
$file = optional_param('filedata', NULL, PARAM_TEXT);
$file = base64_decode($file);
$student = $DB->get_record("user", array("id" => $userid));
$context = get_context_instance(CONTEXT_MODULE, $id);
$fs = get_file_storage();
///Delete old records
$fs->delete_area_files($context->id, 'mod_videoboard', 'private', $fid);
$file_record = new stdClass;
$file_record->component = 'mod_videoboard';
$file_record->contextid = $context->id;
$file_record->userid = $userid;
$file_record->filearea = 'private';
$file_record->filepath = "/";
$file_record->itemid = $fid;
$file_record->license = $CFG->sitedefaultlicense;
$file_record->author = fullname($student);
$file_record->source = '';
$file_record->filename = $filename.".mp3";
$to = $CFG->dataroot."/temp/".$filename.".mp3";
file_put_contents($to, $file);
$itemid = $fs->create_file_from_pathname($file_record, $to);
$json = array("id" => $itemid->get_id());
header("Content-type: text/xml");
$xml_output = "<?xml version=\"1.0\"?>
<result requestid='{$requestid}'>success<error>audio.mp3</error></result>";
echo $xml_output;
unlink($to);