Skip to content

Commit

Permalink
Fix: Removed warning when FirePHP is on
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 5, 2011
1 parent 72e6e95 commit cd04d51
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
33 changes: 31 additions & 2 deletions htdocs/admin/syslog.php
Expand Up @@ -35,6 +35,7 @@
$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;


/*
Expand All @@ -48,6 +49,7 @@

$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"))
{
Expand Down Expand Up @@ -93,6 +95,12 @@
}
}

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();
Expand Down Expand Up @@ -165,19 +173,40 @@
$var=true;

$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_FILE_ON" '.$option.' value="1" '.($syslog_file_on?" checked":"").'> '.$langs->trans("SyslogSimpleFile").'</td>';
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_FILE_ON" '.$option.' value="1" '.($syslog_file_on?' checked="checked"':'').'> '.$langs->trans("SyslogSimpleFile").'</td>';
print '<td width="250" nowrap="nowrap">'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" '.$option.' size="60" value="'.$defaultsyslogfile.'">';
print '</td>';
print "<td align=\"left\">".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT"));
print '</td></tr>';

$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_SYSLOG_ON" '.$option.' value="1" '.($syslog_syslog_on?" checked":"").'> '.$langs->trans("SyslogSyslog").'</td>';
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_SYSLOG_ON" '.$option.' value="1" '.($syslog_syslog_on?' checked="checked"':'').'> '.$langs->trans("SyslogSyslog").'</td>';
print '<td width="250" nowrap="nowrap">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" '.$option.' value="'.$defaultsyslogfacility.'">';
print '</td>';
print "<td align=\"left\">".$html->textwithpicto('','Only LOG_USER supported on Windows');
print '</td></tr>';

try
{
set_include_path('/usr/share/php/');
@require_once('FirePHPCore/FirePHP.class.php');
restore_include_path();
$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_FIREPHP_ON" '.$option.' value="1" ';
if (class_exists('FirePHP')) print ' disabled="disabled"';
else print ($syslog_firephp_on?' checked="checked"':"");
print '> '.$langs->trans("FirePHP").'</td>';
print '<td width="250" nowrap="nowrap">';
print '</td>';
print "<td align=\"left\">".$html->textwithpicto('','FirePHP must be installed onto PHP and FirePHP plugin for Firefox must also be installed');
print '</td></tr>';
}
catch(Exception $e)
{
// Do nothing
print '<!-- FirePHP no available into PHP -->'."\n";
}

print "</table>\n";
print "</form>\n";

Expand Down
18 changes: 14 additions & 4 deletions htdocs/lib/functions.lib.php
Expand Up @@ -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)
{
}
}
}
}
Expand Down

0 comments on commit cd04d51

Please sign in to comment.