From ec9bbe2b52214008f6d6c55bf3dafbb8b8080778 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 16:54:37 +0200 Subject: [PATCH] Help/Need debug of some online instances with the log view --- htdocs/admin/syslog.php | 14 +++++++++++--- htdocs/admin/tools/purge.php | 10 +++++++++- htdocs/core/lib/files.lib.php | 21 +++++++++++++-------- htdocs/document.php | 5 +++-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 65933c25639..75de985728c 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -88,7 +88,7 @@ if ($action == 'set') $newActiveModules = array(); $selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array()); - + // Save options of handler foreach ($syslogModules as $syslogHandler) { @@ -111,7 +111,7 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + 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 @@ -206,7 +206,7 @@ foreach ($syslogModules as $moduleName) //print $moduleName." = ".$moduleactive." - ".$module->getName()." ".($moduleactive == -1)."
\n"; if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL)) continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them) - + print ''; print ''; print ' '; @@ -229,6 +229,14 @@ foreach ($syslogModules as $moduleName) print $option['name'].': '; if (! empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; + + if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/',$value)) + { + $filelogparam =' ('; + $filelogparam.=$langs->trans('Download'); + $filelogparam.=$filelog.')'; + print $filelogparam; + } } } print ''; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index e913d59a4a7..7a5cb30ae75 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -83,7 +83,15 @@ if (! empty($conf->syslog->enabled)) { print ' '.$langs->trans("PurgeDeleteLogFile",$filelog).'

'; + $filelogparam=$filelog; + if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) + { + $filelogparam =''.$filelog.''; + } + print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); + print '

'; } print 'admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); + $original_file=$dolibarr_main_data_root.'/'.$original_file; + } // Wrapping for some images - if (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) + elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) { $accessallowed=1; $original_file=$conf->mycompany->dir_output.'/logos/'.$original_file; @@ -2369,13 +2381,6 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } - // Wrapping for miscellaneous medias files - elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) - { - $accessallowed=1; - $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; - } - // Wrapping for backups else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { diff --git a/htdocs/document.php b/htdocs/document.php index 46e27d57a67..206ea69688a 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -26,6 +26,7 @@ * \brief Wrapper to download data files * \remarks Call of this wrapper is made with URL: * document.php?modulepart=repfichierconcerne&file=pathrelatifdufichier + * document.php?modulepart=logs&file=dolibarr.log */ define('NOTOKENRENEWAL',1); // Disables token renewal @@ -106,7 +107,7 @@ $refname=basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); -$check_access = dol_check_secure_access_document($modulepart,$original_file,$entity,$refname); +$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; // original_file is now a full path name @@ -183,7 +184,7 @@ header('Pragma: public'); //ob_clean(); //flush(); - + readfile($original_file_osencoded); if (is_object($db)) $db->close();