phpmyadmin/libraries/logging.lib.php
Michal Čihař 6fe468f7db Improve syslog integration
- correctly open log
- log only failures

Issue #6146

Signed-off-by: Michal Čihař <michal@cihar.com>
2016-02-17 10:28:04 +01:00

35 lines
807 B
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Logging functionality for webserver.
*
* This includes web server specific code to log some information.
*
* @package PhpMyAdmin
*/
/**
* Logs user information to webserver logs.
*
* @param string $user user name
* @param string $status status message
*
* @return void
*/
function PMA_logUser($user, $status = 'ok')
{
if (function_exists('apache_note')) {
apache_note('userID', $user);
apache_note('userStatus', $status);
}
if (function_exists('syslog') && $status != 'ok') {
@openlog('phpMyAdmin', LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
@syslog(
LOG_WARNING,
'user denied: ' . $user . ' (' . $status . ') from ' .
$_SERVER['REMOTE_ADDR']
);
}
}