original EncodeFile uses is_readable. this fails with files stored in vfs in webusers context. use fopen instead, as old function (version 2.1) did

This commit is contained in:
Klaus Leithoff 2010-04-20 10:02:36 +00:00
parent c2413db67b
commit 9284452553

View File

@ -1491,27 +1491,31 @@ class PHPMailer {
* @return string
*/
private function EncodeFile($path, $encoding = 'base64') {
try {
if (!is_readable($path)) {
throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
}
if (function_exists('get_magic_quotes')) {
function get_magic_quotes() {
return false;
}
}
if (PHP_VERSION < 6) {
$magic_quotes = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
}
$file_buffer = file_get_contents($path);
$file_buffer = $this->EncodeString($file_buffer, $encoding);
if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); }
return $file_buffer;
} catch (Exception $e) {
$this->SetError($e->getMessage());
return '';
}
try {
if (!@$fd = fopen($path,'rb')) {
throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
}
if (function_exists('get_magic_quotes')) {
function get_magic_quotes() {
return false;
}
}
if (PHP_VERSION < 6) {
$magic_quotes = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
}
$file_buffer = file_get_contents($path);
fclose($fd);
$file_buffer = $this->EncodeString($file_buffer, $encoding);
if (PHP_VERSION < 6)
{
set_magic_quotes_runtime($magic_quotes);
}
return $file_buffer;
} catch (Exception $e) {
$this->SetError($e->getMessage());
return '';
}
}
/**