diff --git a/dev/skeletons/skeleton_script.php b/dev/skeletons/skeleton_script.php index 877a420d6af..35904c9bfd3 100644 --- a/dev/skeletons/skeleton_script.php +++ b/dev/skeletons/skeleton_script.php @@ -57,7 +57,7 @@ if (! $result > 0) { dol_print_error('',$user->error); exit; } $user->getrights(); -print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; if (! isset($argv[1])) { // Check parameters print "Usage: ".$script_file." param1 param2 ...\n"; exit(-1); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f658d2550dc..b75c7036719 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2333,7 +2333,7 @@ function dol_print_error($db='',$error='') else // Mode CLI { $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; - $syslog.="pid=".getmypid(); + $syslog.="pid=".dol_getmypid(); } if (is_object($db)) @@ -4742,18 +4742,20 @@ function dol_set_focus($selector) } -if (! function_exists('getmypid')) +/** + * Return getmypid() or random PID when function is disabled + * Some web hosts disable this php function for security reasons + * and sometimes we can't redeclare function + * + * @return int + */ +function dol_getmypid() { - /** - * Return random PID - * Some web hosts disable this php function for security reasons - * - * @return int - */ - function getmypid() - { - return rand(1,32768); - } + if (! function_exists('getmypid')) { + return rand(1,32768); + } else { + return getmypid(); + } } diff --git a/htdocs/includes/phpexcel/PHPExcel/Shared/PDF/tcpdf.php b/htdocs/includes/phpexcel/PHPExcel/Shared/PDF/tcpdf.php index 6a155c19396..47b23913fe3 100644 --- a/htdocs/includes/phpexcel/PHPExcel/Shared/PDF/tcpdf.php +++ b/htdocs/includes/phpexcel/PHPExcel/Shared/PDF/tcpdf.php @@ -11427,7 +11427,7 @@ class TCPDF { } $seed .= uniqid('', true); $seed .= rand(); - $seed .= getmypid(); + $seed .= dol_getmypid(); $seed .= __FILE__; $seed .= $this->bufferlen; if (isset($_SERVER['REMOTE_ADDR'])) { diff --git a/htdocs/includes/tcpdf/include/tcpdf_static.php b/htdocs/includes/tcpdf/include/tcpdf_static.php index 19eccc477b4..bc1e4abcc5b 100644 --- a/htdocs/includes/tcpdf/include/tcpdf_static.php +++ b/htdocs/includes/tcpdf/include/tcpdf_static.php @@ -1358,7 +1358,7 @@ class TCPDF_STATIC { } $seed .= uniqid('', true); $seed .= rand(); - $seed .= getmypid(); + $seed .= dol_getmypid(); $seed .= __FILE__; if (isset($_SERVER['REMOTE_ADDR'])) { $seed .= $_SERVER['REMOTE_ADDR'];