mirror of
https://github.com/moodle/moodle.git
synced 2025-04-27 03:14:20 +02:00
Changes to make uploaded user pictures work properly on Windows :-(
This commit is contained in:
parent
2c855f18c7
commit
2447921f18
@ -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!");
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
15
user/pix.php
15
user/pix.php
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user