From cd04d51ea7b0f86dfd35495c3da21f422c781f27 Mon Sep 17 00:00:00 2001 From: eldy Date: Thu, 6 Oct 2011 00:49:58 +0200 Subject: [PATCH] Fix: Removed warning when FirePHP is on --- htdocs/admin/syslog.php | 33 +++++++++++++++++++++++++++++++-- htdocs/lib/functions.lib.php | 18 ++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 149f537dabb..92559b28a0a 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -35,6 +35,7 @@ $error=0; $mesg=''; $action = GETPOST("action"); $syslog_file_on=(defined('SYSLOG_FILE_ON') && constant('SYSLOG_FILE_ON'))?1:0; $syslog_syslog_on=(defined('SYSLOG_SYSLOG_ON') && constant('SYSLOG_SYSLOG_ON'))?1:0; +$syslog_firephp_on=(defined('SYSLOG_FIREPHP_ON') && constant('SYSLOG_FIREPHP_ON'))?1:0; /* @@ -48,6 +49,7 @@ if ($action == 'set') $res = dolibarr_del_const($db,"SYSLOG_FILE_ON",0); $res = dolibarr_del_const($db,"SYSLOG_SYSLOG_ON",0); + $res = dolibarr_del_const($db,"SYSLOG_FIREPHP_ON",0); if (! $error && GETPOST("filename")) { @@ -93,6 +95,12 @@ if ($action == 'set') } } + if (! $error && isset($_POST['SYSLOG_FIREPHP_ON'])) // If firephp no available, post is not present + { + $syslog_firephp_on=GETPOST('SYSLOG_FIREPHP_ON'); + if (! $error) $res = dolibarr_set_const($db,"SYSLOG_FIREPHP_ON",$syslog_firephp_on,'chaine',0,'',0); + } + if (! $error) { $db->commit(); @@ -165,19 +173,40 @@ print "\n"; $var=true; $var=!$var; -print ' '.$langs->trans("SyslogSimpleFile").''; +print ' '.$langs->trans("SyslogSimpleFile").''; print ''.$langs->trans("SyslogFilename").': '; print ''; print "".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT")); print ''; $var=!$var; -print ' '.$langs->trans("SyslogSyslog").''; +print ' '.$langs->trans("SyslogSyslog").''; print ''.$langs->trans("SyslogFacility").': '; print ''; print "".$html->textwithpicto('','Only LOG_USER supported on Windows'); print ''; +try +{ + set_include_path('/usr/share/php/'); + @require_once('FirePHPCore/FirePHP.class.php'); + restore_include_path(); + $var=!$var; + print ' '.$langs->trans("FirePHP").''; + print ''; + print ''; + print "".$html->textwithpicto('','FirePHP must be installed onto PHP and FirePHP plugin for Firefox must also be installed'); + print ''; +} +catch(Exception $e) +{ + // Do nothing + print ''."\n"; +} + print "\n"; print "\n"; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 9438d318c57..3553d36b442 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -487,10 +487,20 @@ function dol_syslog($message, $level=LOG_INFO) // Check if log is to syslog (SYSLOG_FIREPHP_ON defined) if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON")) { - require_once(SYSLOG_FIREPHP_PATH.'FirePHPCore/FirePHP.class.php'); - ob_start(); - $firephp = FirePHP::getInstance(true); - $firephp->log($message); + try + { + // Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once() a constant from + // database or config file because we must be able to log data before database or config file read. + set_include_path('/usr/share/php/'); + require_once('FirePHPCore/FirePHP.class.php'); + restore_include_path(); + ob_start(); + $firephp = FirePHP::getInstance(true); + $firephp->log($message); + } + catch(Exception $e) + { + } } } }