MDL-26028 fix invalid separator constant and support root dirs in aliases

Credit goes to Loic Jeannin, thanks.
This commit is contained in:
Petr Skoda 2012-04-30 17:54:24 +02:00
parent f7d26a0545
commit e61f888d36

View File

@ -52,7 +52,14 @@ function xsendfile($filepath) {
$aliased = false;
if (!empty($CFG->xsendfilealiases) and is_array($CFG->xsendfilealiases)) {
foreach ($CFG->xsendfilealiases as $alias=>$dir) {
$dir = realpath($dir).PATH_SEPARATOR;
$dir = realpath($dir);
if ($dir === false) {
continue;
}
if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
// add trailing dir separator
$dir .= DIRECTORY_SEPARATOR;
}
if (strpos($filepath, $dir) === 0) {
$filepath = $alias.substr($filepath, strlen($dir));
$aliased = true;