MDL-31558 add missing mimetype to send_temp_file()
[moodle.git] / user / grouppix.php
blobf74669d191ac775ca1c875260ce10840f2040e10
1 <?php
2 // This function fetches group pictures from the data directory
3 // Syntax: pix.php/groupid/f1.jpg or pix.php/groupid/f2.jpg
4 // OR: ?file=groupid/f1.jpg or ?file=groupid/f2.jpg
6 // disable moodle specific debug messages and any errors in output
7 define('NO_DEBUG_DISPLAY', true);
8 define('NO_MOODLE_COOKIES', true); // session not used here
10 require_once('../config.php');
11 require_once($CFG->libdir.'/filelib.php');
13 $relativepath = get_file_argument();
15 $args = explode('/', trim($relativepath, '/'));
17 if (count($args) == 2) {
18 $groupid = (integer)$args[0];
19 $image = $args[1];
20 $pathname = $CFG->dataroot.'/groups/'.$groupid.'/'.$image;
21 } else {
22 $image = 'f1.png';
23 $pathname = $CFG->dirroot.'/pix/g/f1.png';
26 if (file_exists($pathname) and !is_dir($pathname)) {
27 send_file($pathname, $image);
28 } else {
29 header('HTTP/1.0 404 not found');
30 print_error('filenotfound', 'error'); //this is not displayed on IIS??