-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathread_file.php
More file actions
34 lines (27 loc) · 1.02 KB
/
read_file.php
File metadata and controls
34 lines (27 loc) · 1.02 KB
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
<?php
// return a file from the webctimport cache - look for /file.json and redirect to read_rawfile with path
require_once("../../config.php");
require_once("../../lib/filelib.php");
require_once("locallib.php");
require_login();
$path = required_param('path', PARAM_PATH); // directory path
try {
// will check path etc.
$info = webctimport_get_file_info($path);
} catch (Exception $e) {
print_error($e->getMessage());
return;
}
$rawpath = $info->path;
$filename = $info->filename;
$mimetype = '';
if ($info->webcttype=='PAGE_TYPE/Default')
$mimetype = '&mimetype='.urlencode('text/html');
else if (isset($info->mimetype))
$mimetype = '&mimetype='.urlencode($info->mimetype);
if (empty($rawpath)) {
print_error('cannot find path in file information: '.$path);
return;
}
//debugging('get_file redirects to '.$path.' -> '.$rawpath.' (filename '.$filename.')');
redirect($CFG->wwwroot.'/mod/webctimport/read_rawfile.php?path='.urlencode($rawpath).'&filename='.urlencode($filename).$mimetype);