Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / console / plugin / DarkConsoleRequestPlugin.php
blobadba9e73e2e9dd74201da6ebd974068567bb619a
1 <?php
3 final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
5 public function getName() {
6 return pht('Request');
9 public function getDescription() {
10 return pht(
11 'Information about %s and %s.',
12 '$_REQUEST',
13 '$_SERVER');
16 public function generateData() {
17 $addr = idx($_SERVER, 'SERVER_ADDR');
18 if ($addr) {
19 $hostname = @gethostbyaddr($addr);
20 } else {
21 $hostname = null;
24 $controller = $this->getRequest()->getController();
25 if ($controller) {
26 $controller_class = get_class($controller);
27 } else {
28 $controller_class = null;
31 $site = $this->getRequest()->getSite();
32 if ($site) {
33 $site_class = get_class($site);
34 } else {
35 $site_class = null;
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,
51 public function renderPanel() {
52 $data = $this->getData();
54 $special_map = array(
55 'site' => pht('Site'),
56 'controller' => pht('Controller'),
57 'machine' => pht('Machine'),
58 'host' => pht('Host'),
59 'hostname' => pht('Hostname'),
62 $special = idx($data, 'special', array());
64 $rows = array();
65 foreach ($special_map as $key => $label) {
66 $rows[] = array(
67 $label,
68 idx($special, $key),
72 $sections = array();
73 $sections[] = array(
74 'name' => pht('Basics'),
75 'rows' => $rows,
78 $mask = array(
79 'HTTP_COOKIE' => true,
80 'HTTP_X_PHABRICATOR_CSRF' => true,
83 $maps = array(
84 array(
85 'name' => pht('Request'),
86 'data' => idx($data, 'request', array()),
88 array(
89 'name' => pht('Server'),
90 'data' => idx($data, 'server', array()),
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;
106 $rows[] = array(
107 $key,
108 $value,
112 $sections[] = array(
113 'name' => $map['name'],
114 'rows' => $rows,
118 $out = array();
119 foreach ($sections as $section) {
120 $out[] = id(new AphrontTableView($section['rows']))
121 ->setHeaders(
122 array(
123 $section['name'],
124 null,
126 ->setColumnClasses(
127 array(
128 'header',
129 'wide wrap',
132 return $out;