27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35 $langs->loadLangs(array(
"admin",
"other"));
38 $action =
GETPOST(
'action',
'aZ09');
40 $syslogModules = array();
41 $activeModules = array();
43 if (!empty($conf->global->SYSLOG_HANDLERS)) $activeModules = json_decode($conf->global->SYSLOG_HANDLERS);
45 $dirsyslogs = array_merge(array(
'/core/modules/syslog/'), $conf->modules_parts[
'syslog']);
46 foreach ($dirsyslogs as $reldir) {
49 if (is_dir($newdir)) {
50 $handle = opendir($newdir);
52 if (is_resource($handle)) {
53 while (($file = readdir($handle)) !==
false) {
54 if (substr($file, 0, 11) ==
'mod_syslog_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
55 $file = substr($file, 0,
dol_strlen($file) - 4);
57 require_once $newdir.$file.
'.php';
62 if ($module->getVersion() ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
65 if ($module->getVersion() ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
69 $syslogModules[] = $file;
87 $newActiveModules = array();
88 $selectedModules = (
GETPOSTISSET(
'SYSLOG_HANDLERS') ?
GETPOST(
'SYSLOG_HANDLERS') : array());
91 foreach ($syslogModules as $syslogHandler)
93 if (in_array($syslogHandler, $syslogModules))
95 $module =
new $syslogHandler;
97 if (in_array($syslogHandler, $selectedModules)) $newActiveModules[] = $syslogHandler;
98 foreach ($module->configure() as $option)
109 $activeModules = $newActiveModules;
112 dolibarr_set_const($db,
'SYSLOG_HANDLERS', json_encode($activeModules),
'chaine', 0,
'', 0);
115 foreach ($activeModules as $modulename) {
119 $module =
new $modulename;
120 $error = $module->checkConfiguration();
135 if ($action ==
'setlevel')
141 if (!($res > 0)) $error++;
145 $file_saves =
GETPOST(
"file_saves");
147 dol_syslog(
"admin/syslog: file saves ".$file_saves);
149 if (!($res > 0)) $error++;
165 llxHeader(
'', $langs->trans(
"SyslogSetup"));
167 $form =
new Form($db);
169 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
173 $syslogfacility = $defaultsyslogfacility =
dolibarr_get_const($db,
"SYSLOG_FACILITY", 0);
176 if (!$defaultsyslogfacility) $defaultsyslogfacility =
'LOG_USER';
177 if (!$defaultsyslogfile) $defaultsyslogfile =
'dolibarr.log';
179 if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity)
181 print
'<div class="error">'.$langs->trans(
"ContactSuperAdminForChange").
'</div>';
182 $option =
'disabled';
192 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
193 print
'<input type="hidden" name="token" value="'.newToken().
'">';
194 print
'<input type="hidden" name="action" value="set">';
195 print
'<table class="noborder centpercent">';
196 print
'<tr class="liste_titre">';
197 print
'<td>'.$langs->trans(
"Type").
'</td><td>'.$langs->trans(
"Value").
'</td>';
198 print
'<td class="right" colspan="2"><input type="submit" class="button" '.$option.
' value="'.$langs->trans(
"Modify").
'"></td>';
201 foreach ($syslogModules as $moduleName)
203 $module =
new $moduleName;
205 $moduleactive = (int) $module->isActive();
207 if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL))
continue;
210 print
'<tr class="oddeven">';
211 print
'<td width="140">';
212 print
'<input class="oddeven" type="checkbox" name="SYSLOG_HANDLERS[]" value="'.$moduleName.
'" '.(in_array($moduleName, $activeModules) ?
'checked' :
'').($moduleactive <= 0 ?
'disabled' :
'').
'> ';
213 print $module->getName();
214 if ($moduleName ==
'mod_syslog_syslog') {
215 if (!$module->isActive()) {
216 $langs->load(
"errors");
217 print $form->textwithpicto(
'', $langs->trans(
"ErrorPHPNeedModule",
'SysLog'));
222 print
'<td class="nowrap">';
223 $setuparray = $module->configure();
226 foreach ($setuparray as $option)
228 $tmpoption = $option[
'constant'];
229 if (!empty($tmpoption))
232 elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption;
233 }
else $value = (isset($option['default']) ? $option['default'] : '');
235 print $option['
name'].': <input
type="text" class="flat"
name="'.$option['constant'].'" value="'.$value.'"'.(isset($option['attr']) ? ' '.$option['attr'] : '').'>';
236 if (!empty($option['example'])) print '<br>'.$langs->trans("Example").': '.$option['example'];
238 if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/', $value))
240 $filelogparam =
' (<a href="'.DOL_URL_ROOT.
'/document.php?modulepart=logs&file='.basename($value).
'">';
241 $filelogparam .= $langs->trans(
'Download');
242 $filelogparam .=
' '.basename($value).
'</a>)';
249 print
'<td class="left">';
250 if ($module->getInfo())
252 print $form->textwithpicto(
'', $module->getInfo(), 1,
'help');
254 if ($module->getWarning())
256 print $form->textwithpicto(
'', $module->getWarning(), 1,
'warning');
270 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
271 print
'<input type="hidden" name="token" value="'.newToken().
'">';
272 print
'<input type="hidden" name="action" value="setlevel">';
273 print
'<table class="noborder centpercent">';
274 print
'<tr class="liste_titre">';
275 print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
276 print
'<td class="right"><input type="submit" class="button" '.$option.
' value="'.$langs->trans(
"Modify").
'"></td>';
279 print
'<tr class="oddeven"><td width="140">'.$langs->trans(
"SyslogLevel").
'</td>';
280 print
'<td colspan="2"><select class="flat" name="level" '.$option.
'>';
281 print
'<option value="'.LOG_EMERG.
'" '.($conf->global->SYSLOG_LEVEL == LOG_EMERG ?
'SELECTED' :
'').
'>LOG_EMERG ('.LOG_EMERG.
')</option>';
282 print
'<option value="'.LOG_ALERT.
'" '.($conf->global->SYSLOG_LEVEL == LOG_ALERT ?
'SELECTED' :
'').
'>LOG_ALERT ('.LOG_ALERT.
')</option>';
283 print
'<option value="'.LOG_CRIT.
'" '.($conf->global->SYSLOG_LEVEL == LOG_CRIT ?
'SELECTED' :
'').
'>LOG_CRIT ('.LOG_CRIT.
')</option>';
284 print
'<option value="'.LOG_ERR.
'" '.($conf->global->SYSLOG_LEVEL == LOG_ERR ?
'SELECTED' :
'').
'>LOG_ERR ('.LOG_ERR.
')</option>';
285 print
'<option value="'.LOG_WARNING.
'" '.($conf->global->SYSLOG_LEVEL == LOG_WARNING ?
'SELECTED' :
'').
'>LOG_WARNING ('.LOG_WARNING.
')</option>';
286 print
'<option value="'.LOG_NOTICE.
'" '.($conf->global->SYSLOG_LEVEL == LOG_NOTICE ?
'SELECTED' :
'').
'>LOG_NOTICE ('.LOG_NOTICE.
')</option>';
287 print
'<option value="'.LOG_INFO.
'" '.($conf->global->SYSLOG_LEVEL == LOG_INFO ?
'SELECTED' :
'').
'>LOG_INFO ('.LOG_INFO.
')</option>';
288 print
'<option value="'.LOG_DEBUG.
'" '.($conf->global->SYSLOG_LEVEL >= LOG_DEBUG ?
'SELECTED' :
'').
'>LOG_DEBUG ('.LOG_DEBUG.
')</option>';
292 if (!empty($conf->loghandlers[
'mod_syslog_file']) && !empty($conf->cron->enabled)) {
293 print
'<tr class="oddeven"><td width="140">'.$langs->trans(
"SyslogFileNumberOfSaves").
'</td>';
294 print
'<td colspan="2"><input type="number" name="file_saves" placeholder="14" min="0" step="1" value="'.$conf->global->SYSLOG_FILE_SAVES.
'" />';
295 print
' (<a href="'.dol_buildpath(
'/cron/list.php', 1).
'?search_label=CompressSyslogs&status=-1">'.$langs->trans(
'ConfigureCleaningCronjobToSetFrequencyOfSaves').
'</a>)</td></tr>';
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolibarr_get_const($db, $name, $entity=1)
Recupere une constante depuis la base de donnees.
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).
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print
Draft customers invoices.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type