Bumped to 1.6.8
[moodle.git] / user / pix.php
blob838ff8bb0d06417b92211e1c1053e8f85b755eb3
1 <?PHP // $Id$
2 // This function fetches user pictures from the data directory
3 // Syntax: pix.php/userid/f1.jpg or pix.php/userid/f2.jpg
4 // OR: ?file=userid/f1.jpg or ?file=userid/f2.jpg
6 $nomoodlecookie = true; // Because it interferes with caching
8 require_once('../config.php');
9 require_once($CFG->libdir.'/filelib.php');
11 $relativepath = get_file_argument('pix.php');
13 $args = explode('/', trim($relativepath, '/'));
15 if (count($args) == 2) {
16 $userid = (integer)$args[0];
17 $image = $args[1];
18 $pathname = $CFG->dataroot.'/users/'.$userid.'/'.$image;
19 } else {
20 $image = 'f1.png';
21 $pathname = $CFG->dirroot.'/pix/u/f1.png';
24 if (file_exists($pathname) and !is_dir($pathname)) {
25 send_file($pathname, $image);
26 } else {
27 header('HTTP/1.0 404 not found');
28 error(get_string('filenotfound', 'error')); //this is not displayed on IIS??