Fix: We must no enable FirePHP if not in a web context

This commit is contained in:
Laurent Destailleur 2011-11-09 17:18:45 +01:00
parent f620f924e8
commit 7d0a7f569e

View File

@ -42,7 +42,7 @@ if (! function_exists('json_encode'))
function json_encode($elements) function json_encode($elements)
{ {
$num = count($elements); $num = count($elements);
// determine type // determine type
if (is_numeric(key($elements))) if (is_numeric(key($elements)))
{ {
@ -72,11 +72,11 @@ if (! function_exists('json_encode'))
} }
$output.= '}'; $output.= '}';
} }
// return // return
return $output; return $output;
} }
function _val($val) function _val($val)
{ {
if (is_string($val)) return '"'.rawurlencode($val).'"'; if (is_string($val)) return '"'.rawurlencode($val).'"';
@ -99,7 +99,7 @@ if (! function_exists('json_decode'))
function json_decode($json, $assoc=false) function json_decode($json, $assoc=false)
{ {
$comment = false; $comment = false;
$strLength = dol_strlen($json); $strLength = dol_strlen($json);
for ($i=0; $i<$strLength; $i++) for ($i=0; $i<$strLength; $i++)
{ {
@ -113,28 +113,28 @@ if (! function_exists('json_decode'))
else $out.= $json[$i]; else $out.= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
} }
// Return an array // Return an array
eval('$array = '.$out.';'); eval('$array = '.$out.';');
// Return an object // Return an object
if (! $assoc) if (! $assoc)
{ {
if (! empty($array)) if (! empty($array))
{ {
$object = false; $object = false;
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$object->{$key} = $value; $object->{$key} = $value;
} }
return $object; return $object;
} }
return false; return false;
} }
return $array; return $array;
} }
} }
@ -584,7 +584,7 @@ function dol_syslog($message, $level=LOG_INFO)
} }
// Check if log is to syslog (SYSLOG_FIREPHP_ON defined) // Check if log is to syslog (SYSLOG_FIREPHP_ON defined)
if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON")) if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON") && ! empty($_SERVER["SERVER_NAME"])) //! empty($_SERVER["SERVER_NAME"]) to be sure to enable this in Web mode only
{ {
try try
{ {