[-] Core: Fix Swift and TCPDF for hosting which disallow getmypid() php function

This commit is contained in:
Rémi Gaillard
2012-12-10 15:06:03 +01:00
parent 1db4c7875e
commit a68e5c1cfb
2 changed files with 62 additions and 3 deletions
+45 -3
View File
@@ -136,9 +136,9 @@ class PDFGeneratorCore extends TCPDF
$output = 'D';
elseif ($display === false)
$output = 'S';
elseif (display == 'D')
elseif ($display == 'D')
$output = 'D';
elseif (display == 'S')
elseif ($display == 'S')
$output = 'S';
else
$output = 'I';
@@ -160,4 +160,46 @@ class PDFGeneratorCore extends TCPDF
$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;
}
}