28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
38$langs->loadLangs(array(
"admin",
"other"));
41$action =
GETPOST(
'action',
'aZ09');
43$syslogModules = array();
44$activeModules = array();
46if (!empty($conf->global->SYSLOG_HANDLERS)) {
47 $activeModules = json_decode($conf->global->SYSLOG_HANDLERS);
50$dirsyslogs = array_merge(array(
'/core/modules/syslog/'), $conf->modules_parts[
'syslog']);
51foreach ($dirsyslogs as $reldir) {
54 if (is_dir($newdir)) {
55 $handle = opendir($newdir);
57 if (is_resource($handle)) {
58 while (($file = readdir($handle)) !==
false) {
59 if (substr($file, 0, 11) ==
'mod_syslog_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
60 $file = substr($file, 0,
dol_strlen($file) - 4);
62 require_once $newdir.$file.
'.php';
67 if ($module->getVersion() ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
70 if ($module->getVersion() ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
74 $syslogModules[] = $file;
88if ($action ==
'set') {
91 $newActiveModules = array();
92 $selectedModules = (GETPOSTISSET(
'SYSLOG_HANDLERS') ?
GETPOST(
'SYSLOG_HANDLERS') : array());
95 foreach ($syslogModules as $syslogHandler) {
96 if (in_array($syslogHandler, $syslogModules)) {
97 $module =
new $syslogHandler;
99 if (in_array($syslogHandler, $selectedModules)) {
100 $newActiveModules[] = $syslogHandler;
102 foreach ($module->configure() as $option) {
103 if (GETPOSTISSET($option[
'constant'])) {
111 $activeModules = $newActiveModules;
114 dolibarr_set_const($db,
'SYSLOG_HANDLERS', json_encode($activeModules),
'chaine', 0,
'', 0);
117 foreach ($activeModules as $modulename) {
118 $module =
new $modulename;
119 $error = $module->checkConfiguration();
133if ($action ==
'setlevel') {
143 $file_saves =
GETPOST(
"file_saves");
145 dol_syslog(
"admin/syslog: file saves ".$file_saves);
164llxHeader(
'', $langs->trans(
"SyslogSetup"));
166$form =
new Form($db);
168$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
169print
load_fiche_titre($langs->trans(
"SyslogSetup"), $linkback,
'title_setup');
172$syslogfacility = $defaultsyslogfacility =
dolibarr_get_const($db,
"SYSLOG_FACILITY", 0);
175if (!$defaultsyslogfacility) {
176 $defaultsyslogfacility =
'LOG_USER';
178if (!$defaultsyslogfile) {
179 $defaultsyslogfile =
'dolibarr.log';
182if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY) && $user->entity) {
183 print
'<div class="error">'.$langs->trans(
"ContactSuperAdminForChange").
'</div>';
184 $optionmc =
'disabled';
192print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
193print
'<input type="hidden" name="token" value="'.newToken().
'">';
194print
'<input type="hidden" name="action" value="set">';
195print
'<table class="noborder centpercent">';
196print
'<tr class="liste_titre">';
197print
'<td>'.$langs->trans(
"Type").
'</td><td>'.$langs->trans(
"Value").
'</td>';
198print
'<td class="right" colspan="2"><input type="submit" class="button" '.$optionmc.
' value="'.$langs->trans(
"Modify").
'"></td>';
201foreach ($syslogModules as $moduleName) {
202 $module =
new $moduleName;
204 $moduleactive = (int) $module->isActive();
206 if (($moduleactive == -1) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0) {
211 print
'<tr class="oddeven">';
212 print
'<td width="140">';
213 print
'<input class="oddeven" type="checkbox" name="SYSLOG_HANDLERS[]" value="'.$moduleName.
'" '.(in_array($moduleName, $activeModules) ?
'checked' :
'').($moduleactive <= 0 ?
'disabled' :
'').
'> ';
214 print $module->getName();
215 if ($moduleName ==
'mod_syslog_syslog') {
216 if (!$module->isActive()) {
217 $langs->load(
"errors");
218 print $form->textwithpicto(
'', $langs->trans(
"ErrorPHPNeedModule",
'SysLog'));
223 print
'<td class="nowrap">';
224 $setuparray = $module->configure();
226 foreach ($setuparray as $option) {
227 $tmpoption = $option[
'constant'];
228 if (!empty($tmpoption)) {
229 if (GETPOSTISSET($tmpoption)) {
231 } elseif (!empty($conf->global->$tmpoption)) {
232 $value = $conf->global->$tmpoption;
235 $value = (isset($option[
'default']) ? $option[
'default'] :
'');
238 print $option[
'name'].
': <input type="text" class="flat" name="'.$option[
'constant'].
'" value="'.$value.
'"'.(isset($option[
'attr']) ?
' '.$option[
'attr'] :
'').
'>';
239 if (!empty($option[
'example'])) {
240 print
'<br>'.$langs->trans(
"Example").
': '.$option[
'example'];
243 if ($option[
'constant'] ==
'SYSLOG_FILE' && preg_match(
'/^DOL_DATA_ROOT\/[^\/]*$/', $value)) {
244 $filelogparam =
' (<a href="'.DOL_URL_ROOT.
'/document.php?modulepart=logs&file='.basename($value).
'">';
245 $filelogparam .= $langs->trans(
'Download');
246 $filelogparam .=
' '.basename($value).
'</a>)';
253 print
'<td class="left">';
254 if ($module->getInfo()) {
255 print $form->textwithpicto(
'', $module->getInfo(), 1,
'help');
257 if ($module->getWarning()) {
258 print $form->textwithpicto(
'', $module->getWarning(), 1,
'warning');
272print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
273print
'<input type="hidden" name="token" value="'.newToken().
'">';
274print
'<input type="hidden" name="action" value="setlevel">';
275print
'<table class="noborder centpercent">';
276print
'<tr class="liste_titre">';
277print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
278print
'<td class="right"><input type="submit" class="button" '.$optionmc.
' value="'.$langs->trans(
"Modify").
'"></td>';
281print
'<tr class="oddeven"><td width="140">'.$langs->trans(
"SyslogLevel").
'</td>';
282print
'<td colspan="2"><select class="flat" name="level" '.$optionmc.
'>';
283print
'<option value="'.LOG_EMERG.
'" '.($conf->global->SYSLOG_LEVEL == LOG_EMERG ?
'SELECTED' :
'').
'>LOG_EMERG ('.LOG_EMERG.
')</option>';
284print
'<option value="'.LOG_ALERT.
'" '.($conf->global->SYSLOG_LEVEL == LOG_ALERT ?
'SELECTED' :
'').
'>LOG_ALERT ('.LOG_ALERT.
')</option>';
285print
'<option value="'.LOG_CRIT.
'" '.($conf->global->SYSLOG_LEVEL == LOG_CRIT ?
'SELECTED' :
'').
'>LOG_CRIT ('.LOG_CRIT.
')</option>';
286print
'<option value="'.LOG_ERR.
'" '.($conf->global->SYSLOG_LEVEL == LOG_ERR ?
'SELECTED' :
'').
'>LOG_ERR ('.LOG_ERR.
')</option>';
287print
'<option value="'.LOG_WARNING.
'" '.($conf->global->SYSLOG_LEVEL == LOG_WARNING ?
'SELECTED' :
'').
'>LOG_WARNING ('.LOG_WARNING.
')</option>';
288print
'<option value="'.LOG_NOTICE.
'" '.($conf->global->SYSLOG_LEVEL == LOG_NOTICE ?
'SELECTED' :
'').
'>LOG_NOTICE ('.LOG_NOTICE.
')</option>';
289print
'<option value="'.LOG_INFO.
'" '.($conf->global->SYSLOG_LEVEL == LOG_INFO ?
'SELECTED' :
'').
'>LOG_INFO ('.LOG_INFO.
')</option>';
290print
'<option value="'.LOG_DEBUG.
'" '.($conf->global->SYSLOG_LEVEL >= LOG_DEBUG ?
'SELECTED' :
'').
'>LOG_DEBUG ('.LOG_DEBUG.
')</option>';
294if (!empty($conf->loghandlers[
'mod_syslog_file']) && isModEnabled(
'cron')) {
295 print
'<tr class="oddeven"><td width="140">'.$langs->trans(
"SyslogFileNumberOfSaves").
'</td>';
296 print
'<td colspan="2"><input type="number" name="file_saves" placeholder="14" min="0" step="1" value="'.getDolGlobalString(
'SYSLOG_FILE_SAVES').
'" />';
297 print
' (<a href="'.dol_buildpath(
'/cron/list.php', 1).
'?search_label=CompressSyslogs&status=-1">'.$langs->trans(
'ConfigureCleaningCronjobToSetFrequencyOfSaves').
'</a>)</td></tr>';
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
dolibarr_get_const($db, $name, $entity=1)
Get the value of a setup constant from database.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.