Commit 8943aa4d authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '6065-possibility-to-see-logs-in-server-logs-instead-of-the-interface' into '1.4-dev'

Resolve "Possibility to see logs in server logs instead of the interface"

See merge request fusiondirectory/fd!741
parents 03bfeb94 3ac26e51
......@@ -334,6 +334,12 @@ attributetype ( 1.3.6.1.4.1.38414.8.16.4 NAME 'fdDebugLevel'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE)
attributetype ( 1.3.6.1.4.1.38414.8.16.5 NAME 'fdDebugLogging'
DESC 'FusionDirectory - Debug logging'
EQUALITY booleanMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
SINGLE-VALUE )
# Snapshots
attributetype ( 1.3.6.1.4.1.38414.8.17.1 NAME 'fdEnableSnapshots'
......@@ -599,7 +605,7 @@ objectclass ( 1.3.6.1.4.1.38414.8.2.1 NAME 'fusionDirectoryConf'
fdModificationDetectionAttribute $ fdLogging $ fdLdapSizeLimit $ fdWildcardForeignKeys $
fdLoginAttribute $ fdForceSSL $ fdWarnSSL $ fdStoreFilterSettings $ fdSessionLifeTime $
fdHttpAuthActivated $ fdHttpHeaderAuthActivated $ fdHttpHeaderAuthHeaderName $
fdDisplayErrors $ fdLdapMaxQueryTime $ fdLdapStats $ fdDebugLevel $
fdDisplayErrors $ fdLdapMaxQueryTime $ fdLdapStats $ fdDebugLevel $ fdDebugLogging $
fdEnableSnapshots $ fdSnapshotBase $
fdTabHook $ fdShells $ fdDefaultShell $ fdDisplayHookOutput $
fdPluginsMenuBlacklist $ fdManagementConfig $ fdManagementUserConfig $
......
......@@ -105,7 +105,7 @@ if (!is_readable(CONFIG_DIR.'/'.CONFIG_FILE)) {
$config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR);
session::set('config', $config);
session::set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL'));
@DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
logging::debug(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
/* Configuration was reloaded, so plist needs to be as well */
session::un_set('plist');
unset($plist);
......
......@@ -40,9 +40,9 @@ session::start();
reset_errors();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@DEBUG(DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_POST, '_POST');
logging::debug(DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_POST, '_POST');
}
@DEBUG(DEBUG_SESSION, __LINE__, __FUNCTION__, __FILE__, $_SESSION, '_SESSION');
logging::debug(DEBUG_SESSION, __LINE__, __FUNCTION__, __FILE__, $_SESSION, '_SESSION');
/* Logged in? Simple security check */
if (!session::is_set('connected')) {
......@@ -86,7 +86,7 @@ if (session::get('_LAST_PAGE_REQUEST') != '') {
session::set('_LAST_PAGE_REQUEST', time());
@DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
logging::debug(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
/* Set template compile directory */
$smarty->compile_dir = $config->get_cfg_value("templateCompileDirectory", SPOOL_DIR);
......@@ -109,14 +109,14 @@ $smarty->assign('hideMenus', FALSE);
/* check user expiration status */
$expired = $ui->expired_status();
if (($expired == POSIX_WARN_ABOUT_EXPIRATION) && !session::is_set('POSIX_WARN_ABOUT_EXPIRATION__DONE')) {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account ('.$ui->uid.') is about to expire');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account ('.$ui->uid.') is about to expire');
// The users password is about to expire soon, display a warning message.
logging::log('security', 'fusiondirectory', '', [], 'password for user "'.$ui->uid.'" is about to expire');
msg_dialog::display(_('Password change'), _('Your password is about to expire, please change your password!'), INFO_DIALOG);
session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE);
} elseif ($expired == POSIX_FORCE_PASSWORD_CHANGE) {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account expired');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account expired');
// The password is expired, we are now going to enforce a new one from the user.
......
......@@ -72,7 +72,7 @@ class CopyPasteHandler
*/
function add_to_queue ($dn, $action, $type)
{
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue');
if (!in_array($action, ['cut','copy'])) {
trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action));
......@@ -136,7 +136,7 @@ class CopyPasteHandler
*/
protected function load_entry_from_ldap ($entry)
{
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap');
if (!isset($entry['tab_class']) && !isset($entry['type'])) {
return [];
}
......
......@@ -60,7 +60,7 @@ class Language
bindtextdomain($domain, LOCALE_DIR);
textdomain($domain);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, 'Setting language to');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, 'Setting language to');
}
$ret = FALSE;
......@@ -70,7 +70,7 @@ class Language
$ret = TRUE;
if (session::is_set('plist')) {
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, session::get('lang'), 'Plist already loaded with language');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, session::get('lang'), 'Plist already loaded with language');
}
session::un_set('plist');
session::set('lang', $lang);
......
......@@ -965,7 +965,7 @@ class config
if (($tabclass == 'GROUPTABS') && class_available('mixedGroup')) {
$tabclass = 'OGROUP-USERTABS';
}
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class to tab list");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class to tab list");
if (!isset($this->data['TABS'][$tabclass])) {
$this->data['TABS'][$tabclass] = [];
}
......@@ -1007,7 +1007,7 @@ class config
$value['tabClass'] = 'simpleTabs';
}
$this->data['OBJECTS'][strtoupper($key)] = $value;
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class as main tab of");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $tabclass, "Adding $class as main tab of");
if (!isset($this->data['TABS'][$tabclass])) {
$this->data['TABS'][$tabclass] = [];
}
......@@ -1015,7 +1015,7 @@ class config
}
}
} elseif (class_available($class) && is_subclass_of($class, 'simpleService')) {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, "Adding service");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, "Adding service");
if (!isset($this->data['TABS']['SERVERSERVICE'])) {
$this->data['TABS']['SERVERSERVICE'] = [];
}
......@@ -1057,7 +1057,7 @@ class config
];
/* Extract categories definitions from object types */
foreach ($this->data['OBJECTS'] as $key => $infos) {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $infos['aclCategory'], "ObjectType $key category");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $infos['aclCategory'], "ObjectType $key category");
if (strtoupper($infos['aclCategory']) == $key) {
$cat = $infos['aclCategory'];
if (!isset($this->data['CATEGORIES'][$cat])) {
......@@ -1135,7 +1135,7 @@ class config
}
}
}
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, join(',', array_unique($acl)), "Class $class categories");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, join(',', array_unique($acl)), "Class $class categories");
/* Feed menu */
if (isset($plInfo['plSection'])) {
$section = $plInfo['plSection'];
......
......@@ -221,7 +221,7 @@ class LDAP
$this->error = 'Could not connect to LDAP server';
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'connect');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'connect');
}
/*!
......@@ -234,11 +234,11 @@ class LDAP
$this->error = "Success";
$this->hascon = TRUE;
$this->reconnect = TRUE;
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rebind');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rebind');
return 0;
} else {
$this->error = "Could not bind to " . $credentials['ADMINDN'];
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rebind');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rebind');
return NULL;
}
}
......@@ -260,7 +260,7 @@ class LDAP
{
@ldap_unbind($this->cid);
$this->cid = NULL;
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'unbind');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'unbind');
}
/*!
......@@ -272,7 +272,7 @@ class LDAP
@ldap_close($this->cid);
$this->hascon = FALSE;
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'disconnect');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'disconnect');
}
/*!
......@@ -359,11 +359,11 @@ class LDAP
}
$this->log("LDAP operation: time=".$diff." operation=search('".$this->basedn."', '$filter')");
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'search(base="'.$this->basedn.'",scope="'.$scope.'",filter="'.$filter.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'search(base="'.$this->basedn.'",scope="'.$scope.'",filter="'.$filter.'")');
return $this->sr[$srp];
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'search(base="'.$this->basedn.'",scope="'.$scope.'",filter="'.$filter.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'search(base="'.$this->basedn.'",scope="'.$scope.'",filter="'.$filter.'")');
return "";
}
}
......@@ -428,11 +428,11 @@ class LDAP
$this->error = @ldap_error($this->cid);
$this->resetResult($srp);
$this->hasres[$srp] = TRUE;
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'cat(dn="'.$dn.'",filter="'.$filter.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'cat(dn="'.$dn.'",filter="'.$filter.'")');
return $this->sr[$srp];
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'cat(dn="'.$dn.'",filter="'.$filter.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'cat(dn="'.$dn.'",filter="'.$filter.'")');
return "";
}
}
......@@ -451,11 +451,11 @@ class LDAP
$this->connect();
}
$res = @ldap_read($this->cid, $dn, $filter, ["objectClass"]);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'object_match_filter(dn="'.$dn.'",filter="'.$filter.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'object_match_filter(dn="'.$dn.'",filter="'.$filter.'")');
return @ldap_count_entries($this->cid, $res);
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'object_match_filter(dn="'.$dn.'",filter="'.$filter.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'object_match_filter(dn="'.$dn.'",filter="'.$filter.'")');
return FALSE;
}
}
......@@ -476,7 +476,7 @@ class LDAP
} else {
$this->error = "Could not connect to LDAP server";
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $size, 'set_size_limit');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $size, 'set_size_limit');
}
/*!
......@@ -507,16 +507,16 @@ class LDAP
if (!isset($att)) {
$att = [];
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()');
return $att;
} else {
$this->error = "Perform a fetch with no search";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()');
return "";
}
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()');
return "";
}
}
......@@ -582,16 +582,16 @@ class LDAP
if ($this->hasres[$srp]) {
$rv = @ldap_count_entries($this->cid, $this->sr[$srp]);
$this->error = @ldap_error($this->cid);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()');
return $rv;
} else {
$this->error = "Perform a Fetch with no Search";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()');
return "";
}
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'count()');
return "";
}
}
......@@ -616,11 +616,11 @@ class LDAP
$r = ldap_mod_del($this->cid, $dn, $attrs);
$this->error = @ldap_error($this->cid);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rm('.$dn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rm('.$dn.')');
return $r;
} else {
$this->error = 'Could not connect to LDAP server';
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rm('.$dn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rm('.$dn.')');
return '';
}
}
......@@ -637,11 +637,11 @@ class LDAP
$r = @ldap_mod_add($this->cid, $dn, $attrs);
$this->error = @ldap_error($this->cid);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'mod_add('.$dn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'mod_add('.$dn.')');
return $r;
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'mod_add('.$dn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'mod_add('.$dn.')');
return "";
}
}
......@@ -659,11 +659,11 @@ class LDAP
}
$r = @ldap_delete($this->cid, $deletedn);
$this->error = @ldap_error($this->cid);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir('.$deletedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir('.$deletedn.')');
return ($r ? $r : 0);
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir('.$deletedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir('.$deletedn.')');
return "";
}
}
......@@ -713,11 +713,11 @@ class LDAP
/* Check if destination dn exists, if not the
server may not support this operation */
$r &= is_resource($this->dn_exists($dest));
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rename("'.$source.'","'.$dest.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rename("'.$source.'","'.$dest.'")');
return $r;
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rename("'.$source.'","'.$dest.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rename("'.$source.'","'.$dest.'")');
return FALSE;
}
}
......@@ -759,11 +759,11 @@ class LDAP
}
}
$this->error = @ldap_error($this->cid);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir_recursive("'.$deletedn.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir_recursive("'.$deletedn.'")');
return ($r ? $r : 0);
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir_recursive("'.$deletedn.'")');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rmdir_recursive("'.$deletedn.'")');
return "";
}
}
......@@ -789,7 +789,7 @@ class LDAP
$str = " - <b>attribute: ".preg_replace("/:.*$/", "", $this->get_additional_error())."</b>";
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $attrs, "Erroneous data");
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $attrs, "Erroneous data");
return $str;
}
......@@ -813,11 +813,11 @@ class LDAP
if (!$this->success()) {
$this->error .= $this->makeReadableErrors($this->error, $attrs);
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify('.$this->basedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify('.$this->basedn.')');
return ($r ? $r : 0);
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify('.$this->basedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify('.$this->basedn.')');
return "";
}
}
......@@ -838,11 +838,11 @@ class LDAP
}
$r = @ldap_modify_batch($this->cid, $this->basedn, $changes);
$this->error = @ldap_error($this->cid);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify_batch('.$this->basedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify_batch('.$this->basedn.')');
return $r;
} else {
$this->error = 'Could not connect to LDAP server';
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify_batch('.$this->basedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'modify_batch('.$this->basedn.')');
return FALSE;
}
}
......@@ -863,11 +863,11 @@ class LDAP
if (!$this->success()) {
$this->error .= $this->makeReadableErrors($this->error, $attrs);
}
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'add('.$this->basedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'add('.$this->basedn.')');
return ($r ? $r : 0);
} else {
$this->error = "Could not connect to LDAP server";
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'add('.$this->basedn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'add('.$this->basedn.')');
return "";
}
}
......@@ -987,9 +987,9 @@ class LDAP
$this->add($na);
if (!$this->success()) {
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $cdn, 'dn');
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $na, 'Content');
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->get_error(), 'LDAP error');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $cdn, 'dn');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $na, 'Content');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->get_error(), 'LDAP error');
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($this->get_error(), $cdn, LDAP_ADD, get_class()), LDAP_ERROR);
return FALSE;
......@@ -1161,7 +1161,7 @@ class LDAP
function dn_exists ($dn)
{
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'dn_exists('.$dn.')');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'dn_exists('.$dn.')');
return @ldap_read($this->cid, $dn, "(objectClass=*)", ["objectClass"]);
}
......@@ -1518,7 +1518,7 @@ class LDAP
$res = @ldap_read($ds, '', 'objectClass=*', ['namingContexts']);
$attrs = @ldap_get_entries($ds, $res);
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $attrs[0]['namingcontexts'], 'get_naming_contexts');
logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $attrs[0]['namingcontexts'], 'get_naming_contexts');
return $attrs[0]['namingcontexts'];
}
}
......@@ -88,6 +88,66 @@ class logging
}
}
/*!
* \brief Debug output method
*
* Print a DEBUG level if specified debug level of the level matches the
* the configured debug level.
*
* \param int $level The log level of the message (one of the DEBUG_* constants)
*
* \param int $line Line of origin (using __LINE__ is common)
*
* \param string $function Function of origin (using __FUNCTION__ is common)
*
* \param string $file File of origin (using __FILE__ is common)
*
* \param mixed $data Operation result. Can be a message or an array, which is printed with print_a.
*
* \param string $info Operation description
*/
static function debug (int $level, int $line, string $function, string $file, $data, string $info = '')
{
global $config;
static $first = TRUE;
if (($_SERVER['REQUEST_METHOD'] == 'POST') && preg_match('/index.php$/', $_SERVER['REQUEST_URI'])) {
return;
}
if (session::get('DEBUGLEVEL') & $level) {
if ($first) {
echo '<div id="debug-handling" class="notice">'.
'<img src="geticon.php?context=status&amp;icon=dialog-information&amp;size=22" alt="Information" style="vertical-align:middle;margin-right:.2em;"/>'.
'There is some debug output '.
'<button onClick="javascript:$$(\'div.debug_div\').each(function (a) { a.toggle(); });">Toggle</button>'.
'</div>';
$first = FALSE;
}
$output = "DEBUG[$level] ";
if ($function != '') {
$output .= "($file:$function():$line) - $info: ";
} else {
$output .= "($file:$line) - $info: ";
}
echo '<div class="debug_div">';
echo $output;
$logline = $output;
if (is_array($data)) {
print_a($data);
$logline .= print_r($data, TRUE);
} else {
echo "'$data'";
$logline .= "'$data'";
}
echo "</div>\n";
if (is_object($config) && preg_match('/true/i', $config->get_cfg_value('debugLogging', ''))) {
fusiondirectory_log($logline);
}
}
}
/*!
* \brief Check the options
*
......
......@@ -338,7 +338,7 @@ class objects
$tabClass = $infos['tabClass'];
$tabObject = new $tabClass($type, $dn);
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Openned as $type object");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Openned as $type object");
return $tabObject;
}
......@@ -406,7 +406,7 @@ class objects
$attrsObject->is_template = TRUE;
$tabObject = new $tabClass($type, 'new', $attrsObject);
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Create template of $type");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Create template of $type");
return $tabObject;
}
......
......@@ -110,7 +110,7 @@ class passwordRecovery extends standAlonePage
msg_dialog::displayChecks($this->message);
}
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->step, "Step");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->step, "Step");
$smarty = get_smarty();
......@@ -149,7 +149,7 @@ class passwordRecovery extends standAlonePage
$this->loginAttribute = $config->get_cfg_value('passwordRecoveryLoginAttribute', 'uid');
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $config->get_cfg_value('passwordRecoveryActivated'), "passwordRecoveryActivated");
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $config->get_cfg_value('passwordRecoveryActivated'), "passwordRecoveryActivated");
return ($config->get_cfg_value('passwordRecoveryActivated') == "TRUE");
}
......@@ -341,7 +341,7 @@ class passwordRecovery extends standAlonePage
$reinit_link .= '&login='.urlencode($this->login);
$reinit_link .= '&email_address='.urlencode($this->email_address);
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $reinit_link, 'Setting link to');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $reinit_link, 'Setting link to');
/* Send the mail */
$body = sprintf($this->mail_body, $this->login, $reinit_link);
......
......@@ -129,7 +129,7 @@ class standAlonePage
/* Parse configuration file */
$config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR);
session::set('DEBUGLEVEL', $config->get_cfg_value('debuglevel'));
@DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
logging::debug(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
return $config;
}
......
......@@ -100,7 +100,7 @@ function __fusiondirectory_autoload ($class_name)
if (isset($class_mapping["$class_name"])) {
require_once($BASE_DIR.'/'.$class_mapping["$class_name"]);
} else {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class_name, 'Could not load');
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class_name, 'Could not load');
if (isset($config) && is_object($config) &&
$config->get_cfg_value('displayerrors') == 'TRUE') {
list($trace, ) = html_trace();
......@@ -172,34 +172,7 @@ function plugin_available ($plugin)
*/
function DEBUG ($level, $line, $function, $file, $data, $info = '')
{
static $first = TRUE;
if (($_SERVER['REQUEST_METHOD'] == 'POST') && preg_match('/index.php$/', $_SERVER['REQUEST_URI'])) {
return;
}
if (session::get('DEBUGLEVEL') & $level) {
if ($first) {
echo '<div id="debug-handling" class="notice">'.
'<img src="geticon.php?context=status&amp;icon=dialog-information&amp;size=22" alt="Information" style="vertical-align:middle;margin-right:.2em;"/>'.
'There is some debug output '.
'<button onClick="javascript:$$(\'div.debug_div\').each(function (a) { a.toggle(); });">Toggle</button>'.
'</div>';
$first = FALSE;
}
$output = "DEBUG[$level] ";
if ($function != '') {
$output .= "($file:$function():$line) - $info: ";
} else {
$output .= "($file:$line) - $info: ";
}
echo '<div class="debug_div">';
echo $output;
if (is_array($data)) {
print_a($data);
} else {
echo "'$data'";
}