1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* This function fetches group pictures from the data directory.
|
|
|
19 |
*
|
|
|
20 |
* Syntax: pix.php/groupid/f1.jpg or pix.php/groupid/f2.jpg
|
|
|
21 |
* OR: ?file=groupid/f1.jpg or ?file=groupid/f2.jpg
|
|
|
22 |
*
|
|
|
23 |
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
* @package core_user
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
// Disable moodle specific debug messages and any errors in output.
|
|
|
29 |
define('NO_DEBUG_DISPLAY', true);
|
|
|
30 |
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
|
|
31 |
|
|
|
32 |
require_once('../config.php');
|
|
|
33 |
require_once($CFG->libdir.'/filelib.php');
|
|
|
34 |
|
|
|
35 |
$relativepath = get_file_argument();
|
|
|
36 |
|
|
|
37 |
$args = explode('/', trim($relativepath, '/'));
|
|
|
38 |
|
|
|
39 |
if (count($args) == 2) {
|
|
|
40 |
$groupid = (integer)$args[0];
|
|
|
41 |
$image = $args[1];
|
|
|
42 |
$pathname = $CFG->dataroot.'/groups/'.$groupid.'/'.$image;
|
|
|
43 |
} else {
|
|
|
44 |
$image = 'f1.png';
|
|
|
45 |
$pathname = $CFG->dirroot.'/pix/g/f1.png';
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
if (file_exists($pathname) and !is_dir($pathname)) {
|
|
|
49 |
send_file($pathname, $image);
|
|
|
50 |
} else {
|
|
|
51 |
header('HTTP/1.0 404 not found');
|
|
|
52 |
throw new \moodle_exception('filenotfound', 'error'); // This is not displayed on IIS??
|
|
|
53 |
}
|