Skip to content
Snippets Groups Projects
Commit ca6c68ae authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Fix differently pb of not defined COMPUTERNAME.

parent 96df65db
No related branches found
No related tags found
No related merge requests found
...@@ -246,7 +246,7 @@ function dol_syslog($message, $level=LOG_INFO) ...@@ -246,7 +246,7 @@ function dol_syslog($message, $level=LOG_INFO)
$message=$script.$message; $message=$script.$message;
// Add user to log message // Add user to log message
$login=isset($_SERVER['USERNAME'])?$_SERVER['USERNAME']:'nologin'; $login='nologin';
if (is_object($user) && $user->id) $login=$user->login; if (is_object($user) && $user->id) $login=$user->login;
$message=sprintf("%-8s",$login)." ".$message; $message=sprintf("%-8s",$login)." ".$message;
...@@ -260,10 +260,11 @@ function dol_syslog($message, $level=LOG_INFO) ...@@ -260,10 +260,11 @@ function dol_syslog($message, $level=LOG_INFO)
if ($file) if ($file)
{ {
$ip='???'; $ip='???'; // $ip contains information to identify computer that run the code
if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"]; // In most cases. 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['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). else if (! empty($_SERVER['COMPUTERNAME'])) $ip=$_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but usefull if OS defined it).
else if (! empty($_SERVER['LOGNAME'])) $ip='localhost@'.$_SERVER['LOGNAME']; // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
$liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG'); $liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG');
$liblevel=$liblevelarray[$level]; $liblevel=$liblevelarray[$level];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment