* Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/debugbar/class/DataCollector/DolibarrCollector.php * \brief Class for debugbar collection * \ingroup debugbar */ use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; /** * DolibarrCollector class */ class DolibarrCollector extends DataCollector implements Renderable, AssetProvider { /** * Return collector name * * @return string Name */ public function getName() { return 'dolibarr'; } /** * Return collected data * * @return array Array of collected data */ public function collect() { return array(); } /** * Return database info as an HTML string * * @return string HTML string */ protected function getDatabaseInfo() { global $conf, $langs; $info = $langs->trans('Host').': '.$conf->db->host.'
'; $info .= $langs->trans('Port').': '.$conf->db->port.'
'; $info .= $langs->trans('Name').': '.$conf->db->name.'
'; // @phan-suppress-next-line PhanTypeSuspiciousStringExpression $info .= $langs->trans('User').': '.$conf->db->user.'
'; $info .= $langs->trans('Type').': '.$conf->db->type.'
'; $info .= $langs->trans('Prefix').': '.$conf->db->prefix.'
'; $info .= $langs->trans('Charset').': '.$conf->db->character_set.''; return $info; } /** * Return dolibarr info as an HTML string * * @return string HTML string */ protected function getDolibarrInfo() { global $conf, $langs; global $dolibarr_main_prod, $dolibarr_nocsrfcheck; $info = $langs->trans('Version').': '.DOL_VERSION.'
'; $info .= $langs->trans('Theme').': '.$conf->theme.'
'; $info .= $langs->trans('Locale').': ' . getDolGlobalString('MAIN_LANG_DEFAULT').'
'; $info .= $langs->trans('Currency').': '.$conf->currency.'
'; $info .= $langs->trans('Entity').': '.$conf->entity.'
'; $info .= $langs->trans('MaxSizeList').': '.($conf->liste_limit ?: getDolGlobalString('MAIN_SIZE_LISTE_LIMIT')).'
'; $info .= $langs->trans('MaxSizeForUploadedFiles').': ' . getDolGlobalString('MAIN_UPLOAD_DOC').'
'; $info .= '$dolibarr_main_prod = '.$dolibarr_main_prod.'
'; $info .= '$dolibarr_nocsrfcheck = '.$dolibarr_nocsrfcheck.'
'; $info .= 'MAIN_SECURITY_CSRF_WITH_TOKEN = ' . getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN').'
'; $info .= 'MAIN_FEATURES_LEVEL = ' . getDolGlobalString('MAIN_FEATURES_LEVEL').'
'; return $info; } /** * Return mail info as an HTML string * * @return string HTML string */ protected function getMailInfo() { global $conf, $langs; global $dolibarr_mailing_limit_sendbyweb, $dolibarr_mailing_limit_sendbycli, $dolibarr_mailing_limit_sendbyday; $info = $langs->trans('Method').': '.getDolGlobalString("MAIN_MAIL_SENDMODE").'
'; $info .= $langs->trans('Server').': '.getDolGlobalString("MAIN_MAIL_SMTP_SERVER").'
'; $info .= $langs->trans('Port').': '.getDolGlobalString("MAIN_MAIL_SMTP_PORT").'
'; $info .= $langs->trans('ID').': '.getDolGlobalString("MAIN_MAIL_SMTPS_IDT").'
'; $info .= $langs->trans('Pwd').': '.preg_replace('/./', '*', getDolGlobalString("MAIN_MAIL_SMTPS_PW")).'
'; $info .= $langs->trans('TLS/STARTTLS').': '.getDolGlobalString("MAIN_MAIL_EMAIL_TLS").' / '.getDolGlobalString("MAIN_MAIL_EMAIL_STARTTLS").'
'; $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.(!getDolGlobalString('MAIN_DISABLE_ALL_MAILS') ? $langs->trans('No') : $langs->trans('Yes')).'
'; $info .= 'dolibarr_mailing_limit_sendbyweb = '.$dolibarr_mailing_limit_sendbyweb.'
'; $info .= 'dolibarr_mailing_limit_sendbycli = '.$dolibarr_mailing_limit_sendbycli.'
'; $info .= 'dolibarr_mailing_limit_sendbyday = '.$dolibarr_mailing_limit_sendbyday.'
'; return $info; } /** * Return widget settings * * @return array Array */ public function getWidgets() { return array( "database_info" => array( "icon" => "database", "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", "tooltip" => array( "html" => $this->getDatabaseInfo(), "class" => "tooltip-wide" ), "map" => "", "default" => "" ), "dolibarr_info" => array( "icon" => "desktop", "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", "tooltip" => array( "html" => $this->getDolibarrInfo(), "class" => "tooltip-wide" ), "map" => "", "default" => "" ), "mail_info" => array( "icon" => "envelope", "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", "tooltip" => array( "html" => $this->getMailInfo(), "class" => "tooltip-extra-wide" ), "map" => "", "default" => "" ) ); } /** * Return collector assests * * @return array Array */ public function getAssets() { return array( 'base_url' => dol_buildpath('/debugbar', 1), 'js' => 'js/widgets.js', 'css' => 'css/widgets.css' ); } }