|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2023 Laurent Destailleur <[email protected]> |
|
4
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU General Public License |
|
17
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Dolibarr\Tools\DebugBarCollector; |
|
21
|
|
|
|
|
22
|
|
|
use DebugBar\DataCollector\RequestDataCollector; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* \file htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php |
|
26
|
|
|
* \brief Class for debugbar collection |
|
27
|
|
|
* \ingroup debugbar |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* DolRequestDataCollector class |
|
32
|
|
|
*/ |
|
33
|
|
|
class DolRequestDataCollector extends RequestDataCollector |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Collects the data from the collectors |
|
37
|
|
|
* |
|
38
|
|
|
* @return array Array of collected data |
|
39
|
|
|
*/ |
|
40
|
|
|
public function collect() |
|
41
|
|
|
{ |
|
42
|
|
|
$vars = array('_GET', '_POST', '_SESSION', '_COOKIE', '_SERVER'); |
|
43
|
|
|
$data = array(); |
|
44
|
|
|
|
|
45
|
|
|
foreach ($vars as $var) { |
|
46
|
|
|
if (isset($GLOBALS[$var])) { |
|
47
|
|
|
$arrayofvalues = $GLOBALS[$var]; |
|
48
|
|
|
|
|
49
|
|
|
if ($var == '_COOKIE') { |
|
50
|
|
|
foreach ($arrayofvalues as $key => $val) { |
|
51
|
|
|
if (str_starts_with($key, 'DOLSESSID_')) { |
|
52
|
|
|
$arrayofvalues[$key] = '*****hidden*****'; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
//var_dump($arrayofvalues); |
|
56
|
|
|
} |
|
57
|
|
|
if ($var == '_SERVER') { |
|
58
|
|
|
foreach ($arrayofvalues as $key => $val) { |
|
59
|
|
|
if (str_starts_with($key, 'PHP_AUTH_PW')) { |
|
60
|
|
|
$arrayofvalues[$key] = '*****hidden*****'; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
$data["$" . $var] = $this->getDataFormatter()->formatVar($arrayofvalues); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return $data; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Return widget settings |
|
73
|
|
|
* |
|
74
|
|
|
* @return array Array |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getWidgets() |
|
77
|
|
|
{ |
|
78
|
|
|
global $langs; |
|
79
|
|
|
|
|
80
|
|
|
$langs->load("other"); |
|
81
|
|
|
|
|
82
|
|
|
return array( |
|
83
|
|
|
$langs->transnoentities('Variables') => array( |
|
84
|
|
|
"icon" => "tags", |
|
85
|
|
|
"widget" => "PhpDebugBar.Widgets.VariableListWidget", |
|
86
|
|
|
"map" => "request", |
|
87
|
|
|
"default" => "{}" |
|
88
|
|
|
) |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|