30require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
45$langs->loadLangs(array(
"admin",
"other"));
48$action =
GETPOST(
'action',
'aZ09');
50$syslogModules = array();
51$activeModules = array();
54 $activeModules = json_decode(
$conf->global->SYSLOG_HANDLERS);
55 if (!is_array($activeModules)) {
56 $activeModules = array();
60$dirsyslogs = array_merge(array(
'/core/modules/syslog/'),
$conf->modules_parts[
'syslog']);
61foreach ($dirsyslogs as $reldir) {
64 if (is_dir($newdir)) {
65 $handle = opendir($newdir);
67 if (is_resource($handle)) {
68 while (($file = readdir($handle)) !==
false) {
69 if (substr($file, 0, 11) ==
'mod_syslog_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
70 $file = substr($file, 0,
dol_strlen($file) - 4);
73 require_once $newdir.$file.
'.php';
75 if (!class_exists($file)) {
76 dol_syslog(
'admin/syslog.php skipping stale handler '.$file.
' (class not declared)', LOG_WARNING);
79 $module =
new $file();
80 '@phan-var-force LogHandler $module';
81 }
catch (Throwable $e) {
82 dol_syslog(
'admin/syslog.php skipping stale handler '.$file.
': '.$e->getMessage(), LOG_WARNING);
87 if ($module->getVersion() ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
90 if ($module->getVersion() ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
94 $syslogModules[] = $file;
108if ($action ==
'set') {
111 $newActiveModules = array();
112 $selectedModules = (GETPOSTISSET(
'SYSLOG_HANDLERS') ?
GETPOST(
'SYSLOG_HANDLERS') : array());
115 foreach ($syslogModules as $syslogHandler) {
116 if (in_array($syslogHandler, $syslogModules)) {
117 $module =
new $syslogHandler();
118 '@phan-var-force LogHandler $module';
120 if (in_array($syslogHandler, $selectedModules)) {
121 $newActiveModules[] = $syslogHandler;
123 foreach ($module->configure() as $option) {
124 if (GETPOSTISSET($option[
'constant'])) {
132 $activeModules = $newActiveModules;
139 foreach ($activeModules as $modulename) {
140 $module =
new $modulename();
141 '@phan-var-force LogHandler $module';
142 $res = $module->checkConfiguration();
145 $errors = array_merge($errors, $module->errors);
160if ($action ==
'setlevel') {
170 $file_saves =
GETPOST(
"file_saves");
172 dol_syslog(
"admin/syslog: file saves ".$file_saves);
191llxHeader(
'', $langs->trans(
"SyslogSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-syslog');
195$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
197print
load_fiche_titre($langs->trans(
"SyslogSetup"), $linkback,
'title_setup');
203if (!$defaultsyslogfacility) {
204 $defaultsyslogfacility =
'LOG_USER';
206if (!$defaultsyslogfile) {
207 $defaultsyslogfile =
'dolibarr.log';
211 print
'<div class="error">'.$langs->trans(
"ContactSuperAdminForChange").
'</div>';
212 $optionmc =
'disabled';
218print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
222print
'<input type="hidden" name="token" value="'.newToken().
'">';
223print
'<input type="hidden" name="action" value="set">';
225print
'<div class="div-table-responsive-no-min">';
226print
'<table class="noborder centpercent">';
227print
'<tr class="liste_titre">';
228print
'<td>'.$langs->trans(
"Type").
'</td>';
230print
'<td class="center width150"><input type="submit" class="button small" '.$optionmc.
' value="'.$langs->trans(
"Modify").
'"></td>';
233foreach ($syslogModules as $moduleName) {
234 $module =
new $moduleName();
235 '@phan-var-force LogHandler $module';
237 $moduleactive = (int) $module->isActive();
239 if (($moduleactive == -1) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0) {
244 print
'<tr class="oddeven">';
245 print
'<td class="nowraponall" width="140">';
246 print
'<input class="oddeven" type="checkbox" id="syslog_handler_'.$moduleName.
'" name="SYSLOG_HANDLERS[]" value="'.$moduleName.
'" '.(in_array($moduleName, $activeModules) ?
'checked' :
'').($moduleactive <= 0 ?
'disabled' :
'').
'> ';
247 print
'<label for="syslog_handler_'.$moduleName.
'">'.$module->getName().
'</label>';
248 if ($moduleName ==
'mod_syslog_syslog') {
249 if (!$module->isActive()) {
250 $langs->load(
"errors");
251 print $form->textwithpicto(
'', $langs->trans(
"ErrorPHPNeedModule",
'SysLog'));
256 print
'<td class="nowrap">';
257 $setuparray = $module->configure();
260 foreach ($setuparray as $option) {
261 $tmpoption = $option[
'constant'];
263 if (!empty($tmpoption)) {
264 if (GETPOSTISSET($tmpoption)) {
270 $value = (isset($option[
'default']) ? $option[
'default'] :
'');
273 print
'<span class="hideonsmartphone opacitymedium">'.$option[
'name'].
': </span><input type="text" placeholder="'.$option[
'default'].
'" class="flat'.(empty($option[
'css']) ?
'' :
' '.$option[
'css']).
'" name="'.
dol_escape_htmltag($option[
'constant']).
'" value="'.$value.
'"'.(isset($option[
'attr']) ?
' '.$option[
'attr'] :
'').
'>';
274 if (!empty($option[
'example'])) {
278 if ($option[
'constant'] ==
'SYSLOG_FILE' && preg_match(
'/^DOL_DATA_ROOT\/[^\/]*$/', $value)) {
279 $filelogparam =
' <a href="'.DOL_URL_ROOT.
'/document.php?modulepart=logs&file='.basename($value).
'">';
280 $filelogparam .= $langs->trans(
'Download');
281 $filelogparam .=
img_picto($langs->trans(
'Download').
' '.basename($value),
'download',
'class="paddingleft"');
282 $filelogparam .=
'</a>';
289 print
'<td class="center">';
290 if ($module->getInfo()) {
291 print $form->textwithpicto(
'', $module->getInfo(), 1,
'help');
293 if ($module->getWarning()) {
294 print $form->textwithpicto(
'', $module->getWarning(), 1,
'warning');
311print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
315print
'<input type="hidden" name="token" value="'.newToken().
'">';
316print
'<input type="hidden" name="action" value="setlevel">';
318print
'<div class="div-table-responsive-no-min">';
319print
'<table class="noborder centpercent">';
320print
'<tr class="liste_titre">';
321print
'<td>'.$langs->trans(
"Parameter").
'</td><td></td>';
322print
'<td class="center width150"><input type="submit" class="button small" '.$optionmc.
' value="'.$langs->trans(
"Modify").
'"></td>';
325print
'<tr class="oddeven"><td>'.$langs->trans(
"SyslogLevel").
'</td>';
326print
'<td colspan="2"><select class="flat minwidth400" id="level" name="level" '.$optionmc.
'>';
327print
'<option value="'.LOG_EMERG.
'" '.(
getDolGlobalString(
'SYSLOG_LEVEL') == LOG_EMERG ?
'selected' :
'').
'>LOG_EMERG ('.LOG_EMERG.
')</option>';
328print
'<option value="'.LOG_ALERT.
'" '.(
getDolGlobalString(
'SYSLOG_LEVEL') == LOG_ALERT ?
'selected' :
'').
'>LOG_ALERT ('.LOG_ALERT.
')</option>';
329print
'<option value="'.LOG_CRIT.
'" '.(
getDolGlobalString(
'SYSLOG_LEVEL') == LOG_CRIT ?
'selected' :
'').
'>LOG_CRIT ('.LOG_CRIT.
')</option>';
330print
'<option value="'.LOG_ERR.
'" '.(
getDolGlobalString(
'SYSLOG_LEVEL') == LOG_ERR ?
'selected' :
'').
'>LOG_ERR ('.LOG_ERR.
')</option>';
331print
'<option value="'.LOG_WARNING.
'" '.(
getDolGlobalString(
'SYSLOG_LEVEL') == LOG_WARNING ?
'selected' :
'').
'>LOG_WARNING ('.LOG_WARNING.
')</option>';
332print
'<option value="'.LOG_NOTICE.
'" '.(
getDolGlobalString(
'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>';
333print
'<option value="'.LOG_INFO.
'" '.(
getDolGlobalString(
'SYSLOG_LEVEL') == LOG_INFO ?
'selected' :
'').
'>LOG_INFO ('.LOG_INFO.
')</option>';
334print
'<option value="'.LOG_DEBUG.
'" '.(
getDolGlobalString(
'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>';
341 print
'<tr class="oddeven"><td>'.$langs->trans(
"SyslogFileNumberOfSaves").
'</td>';
342 print
'<td colspan="2"><input class="width50" type="number" name="file_saves" placeholder="14" min="0" step="1" value="'.getDolGlobalString(
'SYSLOG_FILE_SAVES').
'" />';
343 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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.