1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Copyright (C) 2023 Laurent Destailleur <[email protected]> |
4
|
|
|
* Copyright (C) 2024 MDW <[email protected]> |
5
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
6
|
|
|
* |
7
|
|
|
* This program is free software; you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Dolibarr\Tools\DebugBarCollector; |
22
|
|
|
|
23
|
|
|
use DebugBar\DataCollector\AssetProvider; |
24
|
|
|
use DebugBar\DataCollector\DataCollector; |
25
|
|
|
use DebugBar\DataCollector\Renderable; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* \file htdocs/debugbar/class/DataCollector/DolibarrCollector.php |
29
|
|
|
* \brief Class for debugbar collection |
30
|
|
|
* \ingroup debugbar |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* DolibarrCollector class |
35
|
|
|
*/ |
36
|
|
|
class DolibarrCollector extends DataCollector implements Renderable, AssetProvider |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Return collector name |
40
|
|
|
* |
41
|
|
|
* @return string Name |
42
|
|
|
*/ |
43
|
|
|
public function getName() |
44
|
|
|
{ |
45
|
|
|
return 'dolibarr'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Return collected data |
50
|
|
|
* |
51
|
|
|
* @return array Array of collected data |
52
|
|
|
*/ |
53
|
|
|
public function collect() |
54
|
|
|
{ |
55
|
|
|
return array(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Return widget settings |
60
|
|
|
* |
61
|
|
|
* @return array Array |
62
|
|
|
*/ |
63
|
|
|
public function getWidgets() |
64
|
|
|
{ |
65
|
|
|
return array( |
66
|
|
|
"database_info" => array( |
67
|
|
|
"icon" => "database", |
68
|
|
|
"indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", |
69
|
|
|
"tooltip" => array( |
70
|
|
|
"html" => $this->getDatabaseInfo(), |
71
|
|
|
"class" => "tooltip-wide" |
72
|
|
|
), |
73
|
|
|
"map" => "", |
74
|
|
|
"default" => "" |
75
|
|
|
), |
76
|
|
|
"dolibarr_info" => array( |
77
|
|
|
"icon" => "desktop", |
78
|
|
|
"indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", |
79
|
|
|
"tooltip" => array( |
80
|
|
|
"html" => $this->getDolibarrInfo(), |
81
|
|
|
"class" => "tooltip-wide" |
82
|
|
|
), |
83
|
|
|
"map" => "", |
84
|
|
|
"default" => "" |
85
|
|
|
), |
86
|
|
|
"mail_info" => array( |
87
|
|
|
"icon" => "envelope", |
88
|
|
|
"indicator" => "PhpDebugBar.DebugBar.TooltipIndicator", |
89
|
|
|
"tooltip" => array( |
90
|
|
|
"html" => $this->getMailInfo(), |
91
|
|
|
"class" => "tooltip-extra-wide" |
92
|
|
|
), |
93
|
|
|
"map" => "", |
94
|
|
|
"default" => "" |
95
|
|
|
) |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Return database info as an HTML string |
101
|
|
|
* |
102
|
|
|
* @return string HTML string |
103
|
|
|
*/ |
104
|
|
|
protected function getDatabaseInfo() |
105
|
|
|
{ |
106
|
|
|
global $conf, $langs; |
107
|
|
|
|
108
|
|
|
$info = $langs->trans('Host') . ': <strong>' . $conf->db->host . '</strong><br>'; |
109
|
|
|
$info .= $langs->trans('Port') . ': <strong>' . $conf->db->port . '</strong><br>'; |
110
|
|
|
$info .= $langs->trans('Name') . ': <strong>' . $conf->db->name . '</strong><br>'; |
111
|
|
|
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression |
112
|
|
|
$info .= $langs->trans('User') . ': <strong>' . $conf->db->user . '</strong><br>'; |
113
|
|
|
$info .= $langs->trans('Type') . ': <strong>' . $conf->db->type . '</strong><br>'; |
114
|
|
|
$info .= $langs->trans('Prefix') . ': <strong>' . $conf->db->prefix . '</strong><br>'; |
115
|
|
|
$info .= $langs->trans('Charset') . ': <strong>' . $conf->db->character_set . '</strong>'; |
116
|
|
|
|
117
|
|
|
return $info; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Return dolibarr info as an HTML string |
122
|
|
|
* |
123
|
|
|
* @return string HTML string |
124
|
|
|
*/ |
125
|
|
|
protected function getDolibarrInfo() |
126
|
|
|
{ |
127
|
|
|
global $conf, $langs; |
128
|
|
|
global $dolibarr_main_prod, $dolibarr_nocsrfcheck; |
129
|
|
|
|
130
|
|
|
$info = $langs->trans('Version') . ': <strong>' . DOL_VERSION . '</strong><br>'; |
131
|
|
|
$info .= $langs->trans('Theme') . ': <strong>' . $conf->theme . '</strong><br>'; |
132
|
|
|
$info .= $langs->trans('Locale') . ': <strong>' . getDolGlobalString('MAIN_LANG_DEFAULT') . '</strong><br>'; |
133
|
|
|
$info .= $langs->trans('Currency') . ': <strong>' . $conf->currency . '</strong><br>'; |
134
|
|
|
$info .= $langs->trans('Entity') . ': <strong>' . $conf->entity . '</strong><br>'; |
135
|
|
|
$info .= $langs->trans('MaxSizeList') . ': <strong>' . ($conf->liste_limit ?: getDolGlobalString('MAIN_SIZE_LISTE_LIMIT')) . '</strong><br>'; |
136
|
|
|
$info .= $langs->trans('MaxSizeForUploadedFiles') . ': <strong>' . getDolGlobalString('MAIN_UPLOAD_DOC') . '</strong><br>'; |
137
|
|
|
$info .= '$dolibarr_main_prod = <strong>' . $dolibarr_main_prod . '</strong><br>'; |
138
|
|
|
$info .= '$dolibarr_nocsrfcheck = <strong>' . $dolibarr_nocsrfcheck . '</strong><br>'; |
139
|
|
|
$info .= 'MAIN_SECURITY_CSRF_WITH_TOKEN = <strong>' . getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN') . '</strong><br>'; |
140
|
|
|
$info .= 'MAIN_FEATURES_LEVEL = <strong>' . getDolGlobalString('MAIN_FEATURES_LEVEL') . '</strong><br>'; |
141
|
|
|
|
142
|
|
|
return $info; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Return mail info as an HTML string |
147
|
|
|
* |
148
|
|
|
* @return string HTML string |
149
|
|
|
*/ |
150
|
|
|
protected function getMailInfo() |
151
|
|
|
{ |
152
|
|
|
global $conf, $langs; |
153
|
|
|
global $dolibarr_mailing_limit_sendbyweb, $dolibarr_mailing_limit_sendbycli, $dolibarr_mailing_limit_sendbyday; |
154
|
|
|
|
155
|
|
|
$info = $langs->trans('Method') . ': <strong>' . getDolGlobalString("MAIN_MAIL_SENDMODE") . '</strong><br>'; |
156
|
|
|
$info .= $langs->trans('Server') . ': <strong>' . getDolGlobalString("MAIN_MAIL_SMTP_SERVER") . '</strong><br>'; |
157
|
|
|
$info .= $langs->trans('Port') . ': <strong>' . getDolGlobalString("MAIN_MAIL_SMTP_PORT") . '</strong><br>'; |
158
|
|
|
$info .= $langs->trans('ID') . ': <strong>' . getDolGlobalString("MAIN_MAIL_SMTPS_IDT") . '</strong><br>'; |
159
|
|
|
$info .= $langs->trans('Pwd') . ': <strong>' . preg_replace('/./', '*', getDolGlobalString("MAIN_MAIL_SMTPS_PW")) . '</strong><br>'; |
160
|
|
|
$info .= $langs->trans('TLS/STARTTLS') . ': <strong>' . getDolGlobalString("MAIN_MAIL_EMAIL_TLS") . '</strong> / <strong>' . getDolGlobalString("MAIN_MAIL_EMAIL_STARTTLS") . '</strong><br>'; |
161
|
|
|
$info .= $langs->trans('MAIN_DISABLE_ALL_MAILS') . ': <strong>' . (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS') ? $langs->trans('No') : $langs->trans('Yes')) . '</strong><br>'; |
162
|
|
|
$info .= 'dolibarr_mailing_limit_sendbyweb = <strong>' . $dolibarr_mailing_limit_sendbyweb . '</strong><br>'; |
163
|
|
|
$info .= 'dolibarr_mailing_limit_sendbycli = <strong>' . $dolibarr_mailing_limit_sendbycli . '</strong><br>'; |
164
|
|
|
$info .= 'dolibarr_mailing_limit_sendbyday = <strong>' . $dolibarr_mailing_limit_sendbyday . '</strong><br>'; |
165
|
|
|
|
166
|
|
|
return $info; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Return collector assests |
171
|
|
|
* |
172
|
|
|
* @return array Array |
173
|
|
|
*/ |
174
|
|
|
public function getAssets() |
175
|
|
|
{ |
176
|
|
|
return array( |
177
|
|
|
'js' => DOL_URL_ROOT . '/templates/src/DebugBar/js/widgets.js', |
178
|
|
|
'css' => DOL_URL_ROOT . '/templates/src/DebugBar/css/widgets.css' |
179
|
|
|
); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|