From 83595f2478cf89efc0af284e0a2520ff529e00d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Nov 2009 14:17:53 +0000 Subject: [PATCH] Fix: Fix differently pb of not defined COMPUTERNAME. --- htdocs/lib/functions.lib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index da028a914ad..29627ce1790 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -260,8 +260,10 @@ function dol_syslog($message, $level=LOG_INFO) if ($file) { - $ip=$_SERVER['SERVER_ADDR']; - if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"]; + $ip='???'; + if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"]; // In most cases. + else if (! empty($_SERVER['SERVER_ADDR'])) $ip=$_SERVER['SERVER_ADDR']; // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) + else if (! empty($_SERVER['COMPUTERNAME'])) $ip=$_SERVER['COMPUTERNAME']; // This is when PHP session is ran outside a web server, like from command line (Not always defined, but usefull on OS define it). $liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG'); $liblevel=$liblevelarray[$level]; @@ -1867,7 +1869,7 @@ function dol_print_error($db='',$error='') global $dolibarr_main_prod; if (empty($dolibarr_main_prod)) print $out; - else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported on browsers. Please read the log file for error message.'; + else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.'; dol_syslog("Error ".$syslog, LOG_ERR); }