2009-10-31 22:02:05 +00:00
|
|
|
<?php
|
2003-12-30 17:18:06 +00:00
|
|
|
// This function fetches group pictures from the data directory
|
|
|
|
// Syntax: pix.php/groupid/f1.jpg or pix.php/groupid/f2.jpg
|
|
|
|
// OR: ?file=groupid/f1.jpg or ?file=groupid/f2.jpg
|
|
|
|
|
2009-10-31 22:02:05 +00:00
|
|
|
// disable moodle specific debug messages and any errors in output
|
|
|
|
define('NO_DEBUG_DISPLAY', true);
|
|
|
|
define('NO_MOODLE_COOKIES', true); // session not used here
|
2003-12-30 17:18:06 +00:00
|
|
|
|
2004-12-14 18:57:51 +00:00
|
|
|
require_once('../config.php');
|
2005-03-07 12:10:22 +00:00
|
|
|
require_once($CFG->libdir.'/filelib.php');
|
2003-12-30 17:18:06 +00:00
|
|
|
|
2009-01-05 21:37:20 +00:00
|
|
|
$relativepath = get_file_argument();
|
2003-12-30 17:18:06 +00:00
|
|
|
|
2004-12-14 18:57:51 +00:00
|
|
|
$args = explode('/', trim($relativepath, '/'));
|
2003-12-30 17:18:06 +00:00
|
|
|
|
2004-12-14 18:57:51 +00:00
|
|
|
if (count($args) == 2) {
|
|
|
|
$groupid = (integer)$args[0];
|
|
|
|
$image = $args[1];
|
|
|
|
$pathname = $CFG->dataroot.'/groups/'.$groupid.'/'.$image;
|
2003-12-30 17:18:06 +00:00
|
|
|
} else {
|
2004-12-14 18:57:51 +00:00
|
|
|
$image = 'f1.png';
|
|
|
|
$pathname = $CFG->dirroot.'/pix/g/f1.png';
|
2003-12-30 17:18:06 +00:00
|
|
|
}
|
|
|
|
|
2004-12-14 18:57:51 +00:00
|
|
|
if (file_exists($pathname) and !is_dir($pathname)) {
|
|
|
|
send_file($pathname, $image);
|
2003-12-30 17:18:06 +00:00
|
|
|
} else {
|
2004-12-14 18:57:51 +00:00
|
|
|
header('HTTP/1.0 404 not found');
|
2008-06-25 17:31:23 +00:00
|
|
|
print_error('filenotfound', 'error'); //this is not displayed on IIS??
|
2003-12-30 17:18:06 +00:00
|
|
|
}
|