getRequestUri());
$file = $this->getPath() . $file;
// make sure that the real path name is actually in the javascript_path, so people can't abuse this to read
// your private data from disk .. otherwise this would be a huge privacy and security issue
if (substr(realpath($file), 0, strlen(realpath($this->getPath()))) != realpath($this->getPath())) {
header("HTTP/1.0 400 Bad Request", true);
echo "
400 - Bad Request
";
die();
}
// if the file doesn't exist or can't be read, give a 404 error
if (! file_exists($file) || ! is_readable($file) || ! is_file($file)) {
header("HTTP/1.0 404 Not Found", true);
echo "404 - Not Found
";
die();
}
$dot = strrpos($file, '.');
if ($dot) {
$ext = strtolower(substr($file, $dot + 1));
if ($ext == 'html' || $ext == 'htm') {
$this->setContentType('text/html');
} elseif ($ext == 'js') {
$this->setContentType('text/javascript');
} elseif ($ext == 'css') {
$this->setContentType('text/css');
} elseif ($ext == 'xml') {
$this->setContentType('text/xml');
} elseif ($ext == 'png') {
$this->setContentType('image/png');
} elseif ($ext == 'gif') {
$this->setContentType('image/gif');
} elseif ($ext == 'jpg' || $ext == 'jpeg') {
$this->setContentType('image/jpeg');
}
}
$this->setCharset('');
$this->setLastModified(filemtime($file));
readfile($file);
}
}