Changes to make uploaded user pictures work properly on Windows :-(

This commit is contained in:
martin 2002-08-09 09:09:36 +00:00
parent 2c855f18c7
commit 2447921f18
3 changed files with 24 additions and 7 deletions

View File

@ -100,6 +100,8 @@
"<A HREF=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</A>");
}
print_table($table);
print_heading("<A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A>");
} else {
error("No users found!");

View File

@ -124,7 +124,11 @@ function print_user_picture($userid, $courseid, $picture, $large=false, $returns
$size = 35;
}
if ($picture) {
$output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
if (iswindows()) { // Workaround for a PATH_INFO problem on Windows PHP
$output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php?file=/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
} else { // Use this method if possible for better caching
$output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
}
} else {
$output .= "<IMG SRC=\"$CFG->wwwroot/user/default/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
}
@ -1576,6 +1580,14 @@ function get_list_of_modules() {
return $mods;
}
function iswindows() {
// True if this is Windows, False if not.
global $WINDIR;
return empty($WINDIR);
}
?>

View File

@ -1,13 +1,17 @@
<?PHP // $Id$
// This function fetches user pictures from the data directory
// Syntax: file.php/userid/f1.jpg
// Syntax: pix.php/userid/f1.jpg or pix.php/userid/f2.jpg
// OR: ?file=userid/f1.jpg or ?file=userid/f2.jpg
require("../config.php");
$lifetime = 86400;
if (!$PATH_INFO) {
error("This script DEPENDS on $PATH_INFO being available. Read the README.");
if (isset($file)) {
$PATH_INFO = $file;
} else if (!$PATH_INFO) {
$PATH_INFO = ""; // Will just show default picture
}
$args = get_slash_arguments();
@ -16,12 +20,11 @@
if ($numargs == 2) {
$userid = (integer)$args[0];
$image = $args[1];
$pathname = "$CFG->dataroot/users/$userid/$image";
} else {
$userid = 0;
$image = "f1.jpg";
$pathname = "$CFG->dirroot/user/default/f1.jpg";
}
$pathname = "$CFG->dataroot/users/$userid/$image";
$lastmodified = filemtime($pathname);
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");