[-] Core: Fix Swift and TCPDF for hosting which disallow getmypid() php function
This commit is contained in:
1 parent
1db4c7875e
commit
a68e5c1cfb
2 files changed
+61
-2
No files matched your search
@@ -226,6 +226,10 @@ class MailCore
|
|||||||
|
|
||||||
/* Create mail and attach differents parts */
|
/* Create mail and attach differents parts */
|
||||||
$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME').'] '.$subject);
|
$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME').'] '.$subject);
|
||||||
|
|
||||||
|
/* Set Message-ID - getmypid() is blocked on some hosting */
|
||||||
|
$message->setId(Mail::generateId());
|
||||||
|
|
||||||
$message->headers->setEncoding('Q');
|
$message->headers->setEncoding('Q');
|
||||||
|
|
||||||
if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_MAIL')))
|
if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_MAIL')))
|
||||||
@@ -339,4 +343,17 @@ class MailCore
|
|||||||
|
|
||||||
return str_replace('"', '"', stripslashes($str));
|
return str_replace('"', '"', stripslashes($str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Rewrite of Swift_Message::generateId() without getmypid() */
|
||||||
|
protected static function generateId($idstring = null)
|
||||||
|
{
|
||||||
|
$midparams = array(
|
||||||
|
"utctime" => gmstrftime("%Y%m%d%H%M%S"),
|
||||||
|
"randint" => mt_rand(),
|
||||||
|
"customstr" => (preg_match("/^(?<!\\.)[a-z0-9\\.]+(?!\\.)\$/iD", $idstring) ? $idstring : "swift") ,
|
||||||
|
"hostname" => (isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : php_uname("n")),
|
||||||
|
);
|
||||||
|
return vsprintf("<%s.%d.%s@%s>", $midparams);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -136,9 +136,9 @@ class PDFGeneratorCore extends TCPDF
|
|||||||
$output = 'D';
|
$output = 'D';
|
||||||
elseif ($display === false)
|
elseif ($display === false)
|
||||||
$output = 'S';
|
$output = 'S';
|
||||||
elseif (display == 'D')
|
elseif ($display == 'D')
|
||||||
$output = 'D';
|
$output = 'D';
|
||||||
elseif (display == 'S')
|
elseif ($display == 'S')
|
||||||
$output = 'S';
|
$output = 'S';
|
||||||
else
|
else
|
||||||
$output = 'I';
|
$output = 'I';
|
||||||
@@ -160,4 +160,46 @@ class PDFGeneratorCore extends TCPDF
|
|||||||
|
|
||||||
$this->writeHTML($this->content, true, false, true, false, '');
|
$this->writeHTML($this->content, true, false, true, false, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override of TCPDF::getRandomSeed() - getmypid() is blocked on several hosting
|
||||||
|
*/
|
||||||
|
protected function getRandomSeed($seed='')
|
||||||
|
{
|
||||||
|
$seed .= microtime();
|
||||||
|
if (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
|
||||||
|
// this is not used on windows systems because it is very slow for a know bug
|
||||||
|
$seed .= openssl_random_pseudo_bytes(512);
|
||||||
|
} else {
|
||||||
|
for ($i = 0; $i < 23; ++$i) {
|
||||||
|
$seed .= uniqid('', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$seed .= uniqid('', true);
|
||||||
|
$seed .= rand();
|
||||||
|
$seed .= __FILE__;
|
||||||
|
$seed .= $this->bufferlen;
|
||||||
|
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||||
|
$seed .= $_SERVER['REMOTE_ADDR'];
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
$seed .= $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['HTTP_ACCEPT'])) {
|
||||||
|
$seed .= $_SERVER['HTTP_ACCEPT'];
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
|
||||||
|
$seed .= $_SERVER['HTTP_ACCEPT_ENCODING'];
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||||
|
$seed .= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
|
||||||
|
$seed .= $_SERVER['HTTP_ACCEPT_CHARSET'];
|
||||||
|
}
|
||||||
|
$seed .= rand();
|
||||||
|
$seed .= uniqid('', true);
|
||||||
|
$seed .= microtime();
|
||||||
|
return $seed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user