diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71d06ae8e64..e3ad8a3616c 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -40,7 +40,7 @@ $action = GETPOST("action"); $syslogModules = array(); $activeModules = array(); -if (defined('SYSLOG_HANDLERS')) $activeModules = json_decode(constant('SYSLOG_HANDLERS')); +if (! empty($conf->global->SYSLOG_HANDLERS)) $activeModules = json_decode($conf->global->SYSLOG_HANDLERS); $dirsyslogs = array_merge(array('/core/modules/syslog/'), $conf->modules_parts['syslog']); foreach ($dirsyslogs as $reldir) { @@ -88,7 +88,8 @@ if ($action == 'set') $newActiveModules = array(); $selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array()); - //var_dump($selectedModules); + + // Save options of handler foreach ($syslogModules as $syslogHandler) { if (in_array($syslogHandler, $syslogModules)) @@ -101,7 +102,7 @@ if ($action == 'set') if (isset($_POST[$option['constant']])) { $_POST[$option['constant']] = trim($_POST[$option['constant']]); - dolibarr_del_const($db, $option['constant'], 0); + dolibarr_del_const($db, $option['constant'], -1); dolibarr_set_const($db, $option['constant'], $_POST[$option['constant']], 'chaine',0, '', 0); } } @@ -109,7 +110,9 @@ if ($action == 'set') } $activeModules = $newActiveModules; - dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0); + + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0); // Check configuration foreach ($activeModules as $modulename) { @@ -217,8 +220,12 @@ foreach ($syslogModules as $moduleName) { foreach ($setuparray as $option) { - if (isset($_POST[$option['constant']])) $value=$_POST[$option['constant']]; - else if (defined($option['constant'])) $value = constant($option['constant']); + $tmpoption=$option['constant']; + if (! empty($tmpoption)) + { + if (isset($_POST[$tmpoption])) $value=$_POST[$tmpoption]; + else if (! empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; + } else $value = (isset($option['default']) ? $option['default'] : ''); print $option['name'].': '; diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 71b643665b3..14e542ff101 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -80,8 +80,11 @@ class box_external_rss extends ModeleBoxes // documents/externalrss is created by module activation // documents/externalrss/tmp is created by rssparser + $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; + $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; + // Get RSS feed - $url=@constant("EXTERNAL_RSS_URLRSS_".$site); + $url=$conf->global->$keyforparamurl; $rssparser=new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); @@ -90,7 +93,7 @@ class box_external_rss extends ModeleBoxes $description=$rssparser->getDescription(); $link=$rssparser->getLink(); - $title=$langs->trans("BoxTitleLastRssInfos",$max, @constant("EXTERNAL_RSS_TITLE_". $site)); + $title=$langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); if ($result < 0 || ! empty($rssparser->error)) { // Show warning diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9446020e3ff..6bca5b7d5a4 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -210,7 +210,7 @@ class Conf $file=dol_sanitizeFileName($file); include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; foreach ($file2bddconsts as $key=>$value) { - $this->global->$key=constant($value); + $this->global->$key=$value; } } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 77da09b3d64..cbf4af402ae 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1495,10 +1495,10 @@ function dol_uncompress($inputfile,$outputdir) { global $conf, $langs; - if (defined('ODTPHP_PATHTOPCLZIP')) + if (! empty($conf->global->ODTPHP_PATHTOPCLZIP)) { - dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".constant('ODTPHP_PATHTOPCLZIP').", so we use Pclzip to unzip into ".$outputdir); - include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; + dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".$conf->global->ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir); + include_once $conf->global->ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; $archive = new PclZip($inputfile); $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir); //var_dump($result); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2620a3b3efc..857ddc6eec2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3570,14 +3570,14 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) $morelabel=' ('.$reg[1].')'; $rate=preg_replace('/\s*'.preg_quote($morelabel,'/').'/','',$rate); } - if (preg_match('/\*/',$rate) || preg_match('/'.constant('MAIN_LABEL_MENTION_NPR').'/i',$rate)) + if (preg_match('/\*/',$rate)) { $rate=str_replace('*','',$rate); $info_bits |= 1; } $ret=price($rate,0,'',0,0).($addpercent?'%':''); - if ($info_bits & 1) $ret.=' '.($usestarfornpr?'*':constant('MAIN_LABEL_MENTION_NPR')); + if ($info_bits & 1) $ret.=' *'; $ret.=$morelabel; return $ret; } diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index cadf133169d..5139128a5d8 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -150,9 +150,9 @@ function dol_loginfunction($langs,$conf,$mysoc) // Title $appli=constant('DOL_APPLICATION_TITLE'); - $title=$appli.' '.DOL_VERSION; + $title=$appli.' '.constant('DOL_VERSION'); if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; - $titletruedolibarrversion=DOL_VERSION; // $title used by login template after the @ to inform of true Dolibarr version + $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version // Note: $conf->css looks like '/theme/eldy/style.css.php' $conf->css = "/theme/".(GETPOST('theme')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php"; diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php index 42a660ab0ae..a9b9ccd5836 100644 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php @@ -48,7 +48,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface { global $langs; - return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php'); + return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php'); } /** @@ -73,7 +73,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface if ($res) { - return 1; + return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler } else { diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 195cab19f7f..68493fd4eb4 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -51,7 +51,8 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface */ public function isActive() { - return 1; + global $conf; + return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FILE)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_FILE to 1 to disable this loghandler } /** diff --git a/htdocs/core/modules/syslog/mod_syslog_firephp.php b/htdocs/core/modules/syslog/mod_syslog_firephp.php index fa6111c80a3..69bc98230af 100644 --- a/htdocs/core/modules/syslog/mod_syslog_firephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_firephp.php @@ -56,7 +56,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface { global $langs; - return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning', self::$firephp_class_path); + return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning', self::$firephp_class_path); } /** @@ -76,7 +76,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface $res = @include_once self::$firephp_class_path; restore_include_path(); if ($res) { - return 1; + return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FIREPHP)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_FIREPHP to 1 to disable this loghandler } else { return 0; } diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index c2885f1c89a..e0283ac9a9f 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -48,10 +48,12 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface */ public function isActive() { + global $conf; + // This function does not exists on some ISP (Ex: Free in France) if (!function_exists('openlog')) return 0; - return 1; + return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler } /** @@ -111,11 +113,11 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return; // Global option to disable output of this handler - if (! empty($conf->global->SYSLOG_FACILITY)) + if (! empty($conf->global->SYSLOG_FACILITY)) // Example LOG_USER { $facility = constant($conf->global->SYSLOG_FACILITY); } - else $facility = LOG_USER; + else $facility = constant('LOG_USER'); // (int) is required to avoid error parameter 3 expected to be long openlog('dolibarr', LOG_PID | LOG_PERROR, (int) $facility); diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php index 158d9fed3da..845760c26b7 100644 --- a/htdocs/ftp/admin/ftpclient.php +++ b/htdocs/ftp/admin/ftpclient.php @@ -247,40 +247,46 @@ else print '