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