30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
40$langs->loadLangs(array(
"admin",
"other"));
43$action =
GETPOST(
'action',
'aZ09');
45$syslogModules = array();
46$activeModules = array();
49 $activeModules = json_decode($conf->global->SYSLOG_HANDLERS);
52$dirsyslogs = array_merge(array(
'/core/modules/syslog/'), $conf->modules_parts[
'syslog']);
53foreach ($dirsyslogs as $reldir) {
56 if (is_dir($newdir)) {
57 $handle = opendir($newdir);
59 if (is_resource($handle)) {
60 while (($file = readdir($handle)) !==
false) {
61 if (substr($file, 0, 11) ==
'mod_syslog_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
62 $file = substr($file, 0,
dol_strlen($file) - 4);
64 require_once $newdir.$file.
'.php';
66 $module =
new $file();
67 '@phan-var-force LogHandler $module';
70 if ($module->getVersion() ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
73 if ($module->getVersion() ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
77 $syslogModules[] = $file;
91if ($action ==
'set') {
94 $newActiveModules = array();
95 $selectedModules = (GETPOSTISSET(
'SYSLOG_HANDLERS') ?
GETPOST(
'SYSLOG_HANDLERS') : array());
98 foreach ($syslogModules as $syslogHandler) {
99 if (in_array($syslogHandler, $syslogModules)) {
100 $module =
new $syslogHandler();
101 '@phan-var-force LogHandler $module';
103 if (in_array($syslogHandler, $selectedModules)) {
104 $newActiveModules[] = $syslogHandler;
106 foreach ($module->configure() as $option) {
107 if (GETPOSTISSET($option[
'constant'])) {
115 $activeModules = $newActiveModules;
118 dolibarr_set_const($db,
'SYSLOG_HANDLERS', json_encode($activeModules),
'chaine', 0,
'', 0);
122 foreach ($activeModules as $modulename) {
123 $module =
new $modulename();
124 '@phan-var-force LogHandler $module';
125 $res = $module->checkConfiguration();
128 $errors = array_merge($errors, $module->errors);
143if ($action ==
'setlevel') {
153 $file_saves =
GETPOST(
"file_saves");
155 dol_syslog(
"admin/syslog: file saves ".$file_saves);
174llxHeader(
'', $langs->trans(
"SyslogSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-syslog');
176$form =
new Form($db);
178$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
179print
load_fiche_titre($langs->trans(
"SyslogSetup"), $linkback,
'title_setup');
182$syslogfacility = $defaultsyslogfacility =
dolibarr_get_const($db,
"SYSLOG_FACILITY", 0);
185if (!$defaultsyslogfacility) {
186 $defaultsyslogfacility =
'LOG_USER';
188if (!$defaultsyslogfile) {
189 $defaultsyslogfile =
'dolibarr.log';
192if (isModEnabled(
'multicompany') && $user->entity) {
193 print
'<div class="error">'.$langs->trans(
"ContactSuperAdminForChange").
'</div>';
194 $optionmc =
'disabled';
200print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
204print
'<input type="hidden" name="token" value="'.newToken().
'">';
205print
'<input type="hidden" name="action" value="set">';
207print
'<div class="div-table-responsive-no-min">';
208print
'<table class="noborder centpercent">';
209print
'<tr class="liste_titre">';
210print
'<td>'.$langs->trans(
"Type").
'</td>';
211print
'<td>'.$langs->trans(
"Value").
'</td>';
212print
'<td class="center width150"><input type="submit" class="button small" '.$optionmc.
' value="'.$langs->trans(
"Modify").
'"></td>';
215foreach ($syslogModules as $moduleName) {
216 $module =
new $moduleName();
217 '@phan-var-force LogHandler $module';
219 $moduleactive = (int) $module->isActive();
221 if (($moduleactive == -1) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0) {
226 print
'<tr class="oddeven">';
227 print
'<td class="nowraponall" width="140">';
228 print
'<input class="oddeven" type="checkbox" id="syslog_handler_'.$moduleName.
'" name="SYSLOG_HANDLERS[]" value="'.$moduleName.
'" '.(in_array($moduleName, $activeModules) ?
'checked' :
'').($moduleactive <= 0 ?
'disabled' :
'').
'> ';
229 print
'<label for="syslog_handler_'.$moduleName.
'">'.$module->getName().
'</label>';
230 if ($moduleName ==
'mod_syslog_syslog') {
231 if (!$module->isActive()) {
232 $langs->load(
"errors");
233 print $form->textwithpicto(
'', $langs->trans(
"ErrorPHPNeedModule",
'SysLog'));
238 print
'<td class="nowrap">';
239 $setuparray = $module->configure();
242 foreach ($setuparray as $option) {
243 $tmpoption = $option[
'constant'];
245 if (!empty($tmpoption)) {
246 if (GETPOSTISSET($tmpoption)) {
252 $value = (isset($option[
'default']) ? $option[
'default'] :
'');
255 print
'<span class="hideonsmartphone opacitymedium">'.$option[
'name'].
': </span><input type="text" class="flat'.(empty($option[
'css']) ?
'' :
' '.$option[
'css']).
'" name="'.
dol_escape_htmltag($option[
'constant']).
'" value="'.$value.
'"'.(isset($option[
'attr']) ?
' '.$option[
'attr'] :
'').
'>';
256 if (!empty($option[
'example'])) {
260 if ($option[
'constant'] ==
'SYSLOG_FILE' && preg_match(
'/^DOL_DATA_ROOT\/[^\/]*$/', $value)) {
261 $filelogparam =
' <a href="'.DOL_URL_ROOT.
'/document.php?modulepart=logs&file='.basename($value).
'">';
262 $filelogparam .= $langs->trans(
'Download');
263 $filelogparam .=
img_picto($langs->trans(
'Download').
' '.basename($value),
'download',
'class="paddingleft"');
264 $filelogparam .=
'</a>';
271 print
'<td class="center">';
272 if ($module->getInfo()) {
273 print $form->textwithpicto(
'', $module->getInfo(), 1,
'help');
275 if ($module->getWarning()) {
276 print $form->textwithpicto(
'', $module->getWarning(), 1,
'warning');
293print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
297print
'<input type="hidden" name="token" value="'.newToken().
'">';
298print
'<input type="hidden" name="action" value="setlevel">';
300print
'<div class="div-table-responsive-no-min">';
301print
'<table class="noborder centpercent">';
302print
'<tr class="liste_titre">';
303print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
304print
'<td class="center width150"><input type="submit" class="button small" '.$optionmc.
' value="'.$langs->trans(
"Modify").
'"></td>';
307print
'<tr class="oddeven"><td>'.$langs->trans(
"SyslogLevel").
'</td>';
308print
'<td colspan="2"><select class="flat minwidth400" id="level" name="level" '.$optionmc.
'>';
309print
'<option value="'.LOG_EMERG.
'" '.($conf->global->SYSLOG_LEVEL == LOG_EMERG ?
'SELECTED' :
'').
'>LOG_EMERG ('.LOG_EMERG.
')</option>';
310print
'<option value="'.LOG_ALERT.
'" '.($conf->global->SYSLOG_LEVEL == LOG_ALERT ?
'SELECTED' :
'').
'>LOG_ALERT ('.LOG_ALERT.
')</option>';
311print
'<option value="'.LOG_CRIT.
'" '.($conf->global->SYSLOG_LEVEL == LOG_CRIT ?
'SELECTED' :
'').
'>LOG_CRIT ('.LOG_CRIT.
')</option>';
312print
'<option value="'.LOG_ERR.
'" '.($conf->global->SYSLOG_LEVEL == LOG_ERR ?
'SELECTED' :
'').
'>LOG_ERR ('.LOG_ERR.
')</option>';
313print
'<option value="'.LOG_WARNING.
'" '.($conf->global->SYSLOG_LEVEL == LOG_WARNING ?
'SELECTED' :
'').
'">LOG_WARNING ('.LOG_WARNING.
')</option>';
314print
'<option value="'.LOG_NOTICE.
'" '.($conf->global->SYSLOG_LEVEL == LOG_NOTICE ?
'SELECTED' :
'').
' data-html="'.
dol_escape_htmltag(
'LOG_NOTICE ('.LOG_NOTICE.
') - <span class="opacitymedium">'.$langs->trans(
"RecommendedForProduction").
'</span>').
'">LOG_NOTICE ('.LOG_NOTICE.
')</option>';
315print
'<option value="'.LOG_INFO.
'" '.($conf->global->SYSLOG_LEVEL == LOG_INFO ?
'SELECTED' :
'').
'>LOG_INFO ('.LOG_INFO.
')</option>';
316print
'<option value="'.LOG_DEBUG.
'" '.($conf->global->SYSLOG_LEVEL >= LOG_DEBUG ?
'SELECTED' :
'').
' data-html="'.
dol_escape_htmltag(
'LOG_DEBUG ('.LOG_DEBUG.
') - <span class="opacitymedium">'.$langs->trans(
"RecommendedForDebug").
'</span>').
'">LOG_DEBUG ('.LOG_DEBUG.
')</option>';
322if (!empty($conf->loghandlers[
'mod_syslog_file']) && isModEnabled(
'cron')) {
323 print
'<tr class="oddeven"><td>'.$langs->trans(
"SyslogFileNumberOfSaves").
'</td>';
324 print
'<td colspan="2"><input class="width50" type="number" name="file_saves" placeholder="14" min="0" step="1" value="'.getDolGlobalString(
'SYSLOG_FILE_SAVES').
'" />';
325 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.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 a 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.