-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththumb.php
More file actions
84 lines (76 loc) · 2.79 KB
/
thumb.php
File metadata and controls
84 lines (76 loc) · 2.79 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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
define('NOCHECKREQUIREDFIELDS', 1);
require('init.php');
require_once('file.php');
require_once('user.php');
$type = param_alpha('type');
switch ($type) {
// A profile icon identified by user ID
case 'profileicon':
safe_require('artefact', 'file');
$userid = param_integer('id');
ArtefactTypeProfileIcon::download_thumbnail_for_user($userid);
exit();
// A profile icon identified by artefact ID
case 'profileiconbyid':
safe_require('artefact', 'file');
$artefactid = param_integer('id');
ArtefactTypeProfileIcon::download_thumbnail($artefactid);
exit();
case 'logobyid':
$filedata = get_record('artefact_file_files', 'artefact', param_integer('id'));
if ($path = get_dataroot_image_path('artefact/file/profileicons', $filedata->fileid, get_imagesize_parameters())) {
if ($filedata->filetype) {
header('Content-type: ' . $filedata->filetype);
if (!get_config('nocache')) {
$maxage = 604800;
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $maxage) .' GMT');
header('Cache-Control: max-age=' . $maxage);
header('Pragma: public');
}
readfile_exit($path);
}
}
// Nothing found, use the site logo.
header('Content-type: ' . 'image/png');
readfile_exit($THEME->get_path('images/site-logo.png'));
case 'blocktype':
$bt = param_alpha('bt'); // blocktype
$ap = param_alpha('ap', null); // artefact plugin (optional)
$basepath = 'blocktype/' . $bt;
if (!empty($ap)) {
$basepath = 'artefact/' . $ap . '/' . $basepath;
}
header('Content-type: image/png');
if (!get_config('nocache')) {
$maxage = 604800;
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $maxage) .' GMT');
header('Cache-Control: max-age=' . $maxage);
header('Pragma: public');
}
$path = $THEME->get_path('images/thumb.png', false, $basepath);
if (is_readable($path)) {
readfile_exit($path);
}
$path = get_config('docroot') . $basepath . '/thumb.png';
if (is_readable($path)) {
readfile_exit($path);
}
readfile_exit($THEME->get_path('images/no_thumbnail.png'));
}
function readfile_exit($path) {
readfile($path);
perf_to_log();
exit;
}