Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/console/plugin/DarkConsoleRequestPlugin.php
13402 views
1
<?php
2
3
final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
4
5
public function getName() {
6
return pht('Request');
7
}
8
9
public function getDescription() {
10
return pht(
11
'Information about %s and %s.',
12
'$_REQUEST',
13
'$_SERVER');
14
}
15
16
public function generateData() {
17
$addr = idx($_SERVER, 'SERVER_ADDR');
18
if ($addr) {
19
$hostname = @gethostbyaddr($addr);
20
} else {
21
$hostname = null;
22
}
23
24
$controller = $this->getRequest()->getController();
25
if ($controller) {
26
$controller_class = get_class($controller);
27
} else {
28
$controller_class = null;
29
}
30
31
$site = $this->getRequest()->getSite();
32
if ($site) {
33
$site_class = get_class($site);
34
} else {
35
$site_class = null;
36
}
37
38
return array(
39
'request' => $_REQUEST,
40
'server' => $_SERVER,
41
'special' => array(
42
'site' => $site_class,
43
'controller' => $controller_class,
44
'machine' => php_uname('n'),
45
'host' => $addr,
46
'hostname' => $hostname,
47
),
48
);
49
}
50
51
public function renderPanel() {
52
$data = $this->getData();
53
54
$special_map = array(
55
'site' => pht('Site'),
56
'controller' => pht('Controller'),
57
'machine' => pht('Machine'),
58
'host' => pht('Host'),
59
'hostname' => pht('Hostname'),
60
);
61
62
$special = idx($data, 'special', array());
63
64
$rows = array();
65
foreach ($special_map as $key => $label) {
66
$rows[] = array(
67
$label,
68
idx($special, $key),
69
);
70
}
71
72
$sections = array();
73
$sections[] = array(
74
'name' => pht('Basics'),
75
'rows' => $rows,
76
);
77
78
$mask = array(
79
'HTTP_COOKIE' => true,
80
'HTTP_X_PHABRICATOR_CSRF' => true,
81
);
82
83
$maps = array(
84
array(
85
'name' => pht('Request'),
86
'data' => idx($data, 'request', array()),
87
),
88
array(
89
'name' => pht('Server'),
90
'data' => idx($data, 'server', array()),
91
),
92
);
93
94
foreach ($maps as $map) {
95
$data = $map['data'];
96
$rows = array();
97
foreach ($data as $key => $value) {
98
if (isset($mask[$key])) {
99
$value = phutil_tag('em', array(), pht('(Masked)'));
100
} else if (is_array($value)) {
101
$value = @json_encode($value);
102
} else {
103
$value = $value;
104
}
105
106
$rows[] = array(
107
$key,
108
$value,
109
);
110
}
111
112
$sections[] = array(
113
'name' => $map['name'],
114
'rows' => $rows,
115
);
116
}
117
118
$out = array();
119
foreach ($sections as $section) {
120
$out[] = id(new AphrontTableView($section['rows']))
121
->setHeaders(
122
array(
123
$section['name'],
124
null,
125
))
126
->setColumnClasses(
127
array(
128
'header',
129
'wide wrap',
130
));
131
}
132
return $out;
133
}
134
}
135
136