Fixed some bad text
[moodle.git] / user / pixgroup.php
blobc5505a204cb08389187b3dcffc9b5739cdce6799
1 <?php // $Id$
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 $nomoodlecookie = true; // Because it interferes with caching
8 require_once("../config.php");
10 $lifetime = 86400;
12 if (isset($file)) { // workaround for situations where / syntax doesn't work
13 $pathinfo = $file;
15 } else {
16 $pathinfo = get_slash_arguments("pixgroup.php");
19 if (! $args = parse_slash_arguments($pathinfo)) {
20 error("No valid arguments supplied");
23 $numargs = count($args);
25 if ($numargs == 2) {
26 $groupid = (integer)$args[0];
27 $image = $args[1];
28 $pathname = "$CFG->dataroot/groups/$groupid/$image";
29 $filetype = "image/jpeg";
30 } else {
31 $pathname = "$CFG->dirroot/pix/g/f1.png";
32 $filetype = "image/png";
35 $lastmodified = filemtime($pathname);
37 if (file_exists($pathname)) {
38 header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
39 header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
40 header("Cache-control: max_age = $lifetime"); // a day
41 header("Pragma: ");
42 header("Content-disposition: inline; filename=$image");
43 header("Content-length: ".filesize($pathname));
44 header("Content-type: $filetype");
45 readfile("$pathname");
48 exit;