2007-05-09 09:24:15
realpath and freeBSD question
After an ugrade on my server from FreBSD FreeBSD 5.5 to 6.2 my ATutor installation suddenly couldn't fetch content (my content dir is outside web scope) with get.php. The problems seems to be related to freeBSD's handling of realpath() in PHP.
The following changes to get.php solved it and the solution maybe interesting for others?
I have tested the new code and it seems to work fine, but have any of you comments or idea why it may not work in certain situations or?
Things to describe:
operating system - FreeBSD 6.2
version of ATutor - 1.5.3.2
versions of php - 5.2.1
version of mysq l - 5.0.37
webserver & version - Apache 1.3.37
copies of error messages -
changes to default settings - in get.php the following changes (starting line 92) have been made:
[php]// NOTE!! for some reason realpath() is not returning FALSE when the file doesn't exist! NOTE!!
#$real = realpath('/usr'.$file);
$real = $file;
//If (file_exists($real) && (substr($real, 0, strlen(AT_CONTENT_DIR)) == AT_CONTENT_DIR)) {
if ($force_download) {
header('Content-Type: application/force-download');
header('Content-transfer-encoding: binary');
header('Content-Disposition: attachment; filename="'.$pathinfo['basename'].'"');
} else {
header('Content-Disposition: filename="'.$pathinfo['basename'].'"');
}
header('Content-Type: '.$ext);
echo file_get_contents($file);
exit;
//} else {
//header('HTTP/1.1 404 Not Found', TRUE);
// exit;
//}[/php]
web browser being used -
and anything else relevant -