mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 20:31:31 +02:00
rework of EncodeFile to avoid opening the file in question twice
This commit is contained in:
parent
1c72c8e9e0
commit
1afe8f6f9a
@ -1490,29 +1490,36 @@ class PHPMailer {
|
|||||||
* @access private
|
* @access private
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function EncodeFile($path, $encoding = 'base64') {
|
private function EncodeFile($path, $encoding = 'base64')
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (!@$fd = fopen($path,'rb')) {
|
if ((@$file_buffer = file_get_contents($path."bak"))===false)
|
||||||
|
{
|
||||||
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')) {
|
|
||||||
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);
|
$file_buffer = $this->EncodeString($file_buffer, $encoding);
|
||||||
if (PHP_VERSION < 6)
|
if (PHP_VERSION < 6)
|
||||||
{
|
{
|
||||||
set_magic_quotes_runtime($magic_quotes);
|
set_magic_quotes_runtime($magic_quotes);
|
||||||
}
|
}
|
||||||
return $file_buffer;
|
return $file_buffer;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
if (PHP_VERSION < 6)
|
||||||
|
{
|
||||||
|
set_magic_quotes_runtime($magic_quotes);
|
||||||
|
}
|
||||||
$this->SetError($e->getMessage());
|
$this->SetError($e->getMessage());
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user