[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/console/plugin/ -> DarkConsoleRequestPlugin.php (source)

   1  <?php
   2  
   3  final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
   4  
   5    public function getName() {
   6      return 'Request';
   7    }
   8  
   9    public function getDescription() {
  10      return 'Information about $_REQUEST and $_SERVER.';
  11    }
  12  
  13    public function generateData() {
  14      return array(
  15        'Request'  => $_REQUEST,
  16        'Server'   => $_SERVER,
  17      );
  18    }
  19  
  20    public function renderPanel() {
  21      $data = $this->getData();
  22  
  23      $sections = array(
  24        'Basics' => array(
  25          'Machine'   => php_uname('n'),
  26        ),
  27      );
  28  
  29      // NOTE: This may not be present for some SAPIs, like php-fpm.
  30      if (!empty($data['Server']['SERVER_ADDR'])) {
  31        $addr = $data['Server']['SERVER_ADDR'];
  32        $sections['Basics']['Host'] = $addr;
  33        $sections['Basics']['Hostname'] = @gethostbyaddr($addr);
  34      }
  35  
  36      $sections = array_merge($sections, $data);
  37  
  38      $mask = array(
  39        'HTTP_COOKIE' => true,
  40        'HTTP_X_PHABRICATOR_CSRF' => true,
  41      );
  42  
  43      $out = array();
  44      foreach ($sections as $header => $map) {
  45        $rows = array();
  46        foreach ($map as $key => $value) {
  47          if (isset($mask[$key])) {
  48            $rows[] = array(
  49              $key,
  50              phutil_tag('em', array(), '(Masked)'),
  51            );
  52          } else {
  53            $rows[] = array(
  54              $key,
  55              (is_array($value) ? json_encode($value) : $value),
  56            );
  57          }
  58        }
  59  
  60        $table = new AphrontTableView($rows);
  61        $table->setHeaders(
  62          array(
  63            $header,
  64            null,
  65          ));
  66        $table->setColumnClasses(
  67          array(
  68            'header',
  69            'wide wrap',
  70          ));
  71        $out[] = $table->render();
  72      }
  73  
  74      return phutil_implode_html("\n", $out);
  75    }
  76  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1