Files: add public / protected / private

This commit is contained in:
terrafrost 2016-12-11 08:23:59 -06:00
parent 1dfd315725
commit 242e0dcb7f
4 changed files with 279 additions and 279 deletions

View File

@ -35,7 +35,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $max_x; private $max_x;
/** /**
* Max Height * Max Height
@ -43,7 +43,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $max_y; private $max_y;
/** /**
* Max History * Max History
@ -51,7 +51,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $max_history; private $max_history;
/** /**
* History * History
@ -59,7 +59,7 @@ class ANSI
* @var array * @var array
* @access private * @access private
*/ */
var $history; private $history;
/** /**
* History Attributes * History Attributes
@ -67,7 +67,7 @@ class ANSI
* @var array * @var array
* @access private * @access private
*/ */
var $history_attrs; private $history_attrs;
/** /**
* Current Column * Current Column
@ -75,7 +75,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $x; private $x;
/** /**
* Current Row * Current Row
@ -83,7 +83,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $y; private $y;
/** /**
* Old Column * Old Column
@ -91,7 +91,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $old_x; private $old_x;
/** /**
* Old Row * Old Row
@ -99,7 +99,7 @@ class ANSI
* @var int * @var int
* @access private * @access private
*/ */
var $old_y; private $old_y;
/** /**
* An empty attribute cell * An empty attribute cell
@ -107,7 +107,7 @@ class ANSI
* @var object * @var object
* @access private * @access private
*/ */
var $base_attr_cell; private $base_attr_cell;
/** /**
* The current attribute cell * The current attribute cell
@ -115,7 +115,7 @@ class ANSI
* @var object * @var object
* @access private * @access private
*/ */
var $attr_cell; private $attr_cell;
/** /**
* An empty attribute row * An empty attribute row
@ -123,7 +123,7 @@ class ANSI
* @var array * @var array
* @access private * @access private
*/ */
var $attr_row; private $attr_row;
/** /**
* The current screen text * The current screen text
@ -131,7 +131,7 @@ class ANSI
* @var array * @var array
* @access private * @access private
*/ */
var $screen; private $screen;
/** /**
* The current screen attributes * The current screen attributes
@ -139,7 +139,7 @@ class ANSI
* @var array * @var array
* @access private * @access private
*/ */
var $attrs; private $attrs;
/** /**
* Current ANSI code * Current ANSI code
@ -147,7 +147,7 @@ class ANSI
* @var string * @var string
* @access private * @access private
*/ */
var $ansi; private $ansi;
/** /**
* Tokenization * Tokenization
@ -155,7 +155,7 @@ class ANSI
* @var array * @var array
* @access private * @access private
*/ */
var $tokenization; private $tokenization;
/** /**
* Default Constructor. * Default Constructor.
@ -163,7 +163,7 @@ class ANSI
* @return \phpseclib\File\ANSI * @return \phpseclib\File\ANSI
* @access public * @access public
*/ */
function __construct() public function __construct()
{ {
$attr_cell = new \stdClass(); $attr_cell = new \stdClass();
$attr_cell->bold = false; $attr_cell->bold = false;
@ -188,7 +188,7 @@ class ANSI
* @param int $y * @param int $y
* @access public * @access public
*/ */
function setDimensions($x, $y) public function setDimensions($x, $y)
{ {
$this->max_x = $x - 1; $this->max_x = $x - 1;
$this->max_y = $y - 1; $this->max_y = $y - 1;
@ -207,7 +207,7 @@ class ANSI
* @param int $y * @param int $y
* @access public * @access public
*/ */
function setHistory($history) public function setHistory($history)
{ {
$this->max_history = $history; $this->max_history = $history;
} }
@ -218,7 +218,7 @@ class ANSI
* @param string $source * @param string $source
* @access public * @access public
*/ */
function loadString($source) public function loadString($source)
{ {
$this->setDimensions($this->max_x + 1, $this->max_y + 1); $this->setDimensions($this->max_x + 1, $this->max_y + 1);
$this->appendString($source); $this->appendString($source);
@ -230,7 +230,7 @@ class ANSI
* @param string $source * @param string $source
* @access public * @access public
*/ */
function appendString($source) public function appendString($source)
{ {
$this->tokenization = ['']; $this->tokenization = [''];
for ($i = 0; $i < strlen($source); $i++) { for ($i = 0; $i < strlen($source); $i++) {
@ -283,7 +283,7 @@ class ANSI
case "\x1B(B": // set united states g0 character set case "\x1B(B": // set united states g0 character set
break; break;
case "\x1BE": // Move to next line case "\x1BE": // Move to next line
$this->_newLine(); $this->newLine();
$this->x = 0; $this->x = 0;
break; break;
default: default:
@ -379,7 +379,7 @@ class ANSI
$this->x = 0; $this->x = 0;
break; break;
case "\n": case "\n":
$this->_newLine(); $this->newLine();
break; break;
case "\x08": // backspace case "\x08": // backspace
if ($this->x) { if ($this->x) {
@ -431,7 +431,7 @@ class ANSI
* *
* @access private * @access private
*/ */
function _newLine() private function newLine()
{ {
//if ($this->y < $this->max_y) { //if ($this->y < $this->max_y) {
// $this->y++; // $this->y++;
@ -460,7 +460,7 @@ class ANSI
* @access private * @access private
* @return string * @return string
*/ */
function _processCoordinate($last_attr, $cur_attr, $char) private function processCoordinate($last_attr, $cur_attr, $char)
{ {
$output = ''; $output = '';
@ -517,21 +517,21 @@ class ANSI
* @access private * @access private
* @return string * @return string
*/ */
function _getScreen() private function getScreenHelper()
{ {
$output = ''; $output = '';
$last_attr = $this->base_attr_cell; $last_attr = $this->base_attr_cell;
for ($i = 0; $i <= $this->max_y; $i++) { for ($i = 0; $i <= $this->max_y; $i++) {
for ($j = 0; $j <= $this->max_x; $j++) { for ($j = 0; $j <= $this->max_x; $j++) {
$cur_attr = $this->attrs[$i][$j]; $cur_attr = $this->attrs[$i][$j];
$output.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); $output.= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : '');
$last_attr = $this->attrs[$i][$j]; $last_attr = $this->attrs[$i][$j];
} }
$output.= "\r\n"; $output.= "\r\n";
} }
$output = substr($output, 0, -2); $output = substr($output, 0, -2);
// close any remaining open tags // close any remaining open tags
$output.= $this->_processCoordinate($last_attr, $this->base_attr_cell, ''); $output.= $this->processCoordinate($last_attr, $this->base_attr_cell, '');
return rtrim($output); return rtrim($output);
} }
@ -541,9 +541,9 @@ class ANSI
* @access public * @access public
* @return string * @return string
*/ */
function getScreen() public function getScreen()
{ {
return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $this->_getScreen() . '</pre>'; return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $this->getScreenHelper() . '</pre>';
} }
/** /**
@ -552,21 +552,21 @@ class ANSI
* @access public * @access public
* @return string * @return string
*/ */
function getHistory() public function getHistory()
{ {
$scrollback = ''; $scrollback = '';
$last_attr = $this->base_attr_cell; $last_attr = $this->base_attr_cell;
for ($i = 0; $i < count($this->history); $i++) { for ($i = 0; $i < count($this->history); $i++) {
for ($j = 0; $j <= $this->max_x + 1; $j++) { for ($j = 0; $j <= $this->max_x + 1; $j++) {
$cur_attr = $this->history_attrs[$i][$j]; $cur_attr = $this->history_attrs[$i][$j];
$scrollback.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); $scrollback.= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : '');
$last_attr = $this->history_attrs[$i][$j]; $last_attr = $this->history_attrs[$i][$j];
} }
$scrollback.= "\r\n"; $scrollback.= "\r\n";
} }
$base_attr_cell = $this->base_attr_cell; $base_attr_cell = $this->base_attr_cell;
$this->base_attr_cell = $last_attr; $this->base_attr_cell = $last_attr;
$scrollback.= $this->_getScreen(); $scrollback.= $this->getScreen();
$this->base_attr_cell = $base_attr_cell; $this->base_attr_cell = $base_attr_cell;
return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $scrollback . '</span></pre>'; return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $scrollback . '</span></pre>';

View File

@ -109,7 +109,7 @@ abstract class ASN1
* @access private * @access private
* @link http://en.wikipedia.org/wiki/Object_identifier * @link http://en.wikipedia.org/wiki/Object_identifier
*/ */
static $oids = []; private static $oids = [];
/** /**
* ASN.1 object identifier reverse mapping * ASN.1 object identifier reverse mapping
@ -117,7 +117,7 @@ abstract class ASN1
* @var array * @var array
* @access private * @access private
*/ */
static $reverseOIDs = []; private static $reverseOIDs = [];
/** /**
* Default date format * Default date format
@ -126,7 +126,7 @@ abstract class ASN1
* @access private * @access private
* @link http://php.net/class.datetime * @link http://php.net/class.datetime
*/ */
static $format = 'D, d M Y H:i:s O'; private static $format = 'D, d M Y H:i:s O';
/** /**
* Filters * Filters
@ -135,9 +135,9 @@ abstract class ASN1
* *
* @var array * @var array
* @access private * @access private
* @see self::_encode_der() * @see self::encode_der()
*/ */
static $filters; private static $filters;
/** /**
* Current Location of most recent ASN.1 encode process * Current Location of most recent ASN.1 encode process
@ -146,9 +146,9 @@ abstract class ASN1
* *
* @var array * @var array
* @access private * @access private
* @see self::_encode_der() * @see self::encode_der()
*/ */
static $location; private static $location;
/** /**
* DER Encoded String * DER Encoded String
@ -159,7 +159,7 @@ abstract class ASN1
* @access private * @access private
* @see self::decodeDER() * @see self::decodeDER()
*/ */
static $encoded; private static $encoded;
/** /**
* Type mapping table for the ANY type. * Type mapping table for the ANY type.
@ -224,7 +224,7 @@ abstract class ASN1
* @return array * @return array
* @access public * @access public
*/ */
static function decodeBER($encoded) public static function decodeBER($encoded)
{ {
if ($encoded instanceof Element) { if ($encoded instanceof Element) {
$encoded = $encoded->element; $encoded = $encoded->element;
@ -232,7 +232,7 @@ abstract class ASN1
self::$encoded = $encoded; self::$encoded = $encoded;
$decoded = [self::_decode_ber($encoded)]; $decoded = [self::decode_ber($encoded)];
// encapsulate in an array for BC with the old decodeBER // encapsulate in an array for BC with the old decodeBER
return $decoded; return $decoded;
@ -251,7 +251,7 @@ abstract class ASN1
* @return array * @return array
* @access private * @access private
*/ */
static function _decode_ber($encoded, $start = 0, $encoded_pos = 0) private static function decode_ber($encoded, $start = 0, $encoded_pos = 0)
{ {
$current = ['start' => $start]; $current = ['start' => $start];
@ -328,7 +328,7 @@ abstract class ASN1
$newcontent = []; $newcontent = [];
$remainingLength = $length; $remainingLength = $length;
while ($remainingLength > 0) { while ($remainingLength > 0) {
$temp = self::_decode_ber($content, $start, $content_pos); $temp = self::decode_ber($content, $start, $content_pos);
$length = $temp['length']; $length = $temp['length'];
// end-of-content octets - see paragraph 8.1.5 // end-of-content octets - see paragraph 8.1.5
if (substr($content, $content_pos + $length, 2) == "\0\0") { if (substr($content, $content_pos + $length, 2) == "\0\0") {
@ -379,7 +379,7 @@ abstract class ASN1
if (!$constructed) { if (!$constructed) {
$current['content'] = substr($content, $content_pos); $current['content'] = substr($content, $content_pos);
} else { } else {
$temp = self::_decode_ber($content, $start, $content_pos); $temp = self::decode_ber($content, $start, $content_pos);
$length-= (strlen($content) - $content_pos); $length-= (strlen($content) - $content_pos);
$last = count($temp) - 1; $last = count($temp) - 1;
for ($i = 0; $i < $last; $i++) { for ($i = 0; $i < $last; $i++) {
@ -403,7 +403,7 @@ abstract class ASN1
$current['content'] = ''; $current['content'] = '';
$length = 0; $length = 0;
while (substr($content, $content_pos, 2) != "\0\0") { while (substr($content, $content_pos, 2) != "\0\0") {
$temp = self::_decode_ber($content, $length + $start, $content_pos); $temp = self::decode_ber($content, $length + $start, $content_pos);
$content_pos += $temp['length']; $content_pos += $temp['length'];
// all subtags should be octet strings // all subtags should be octet strings
//if ($temp['type'] != self::TYPE_OCTET_STRING) { //if ($temp['type'] != self::TYPE_OCTET_STRING) {
@ -435,7 +435,7 @@ abstract class ASN1
$length = $offset + 2; // +2 for the EOC $length = $offset + 2; // +2 for the EOC
break 2; break 2;
} }
$temp = self::_decode_ber($content, $start + $offset, $content_pos); $temp = self::decode_ber($content, $start + $offset, $content_pos);
$content_pos += $temp['length']; $content_pos += $temp['length'];
$current['content'][] = $temp; $current['content'][] = $temp;
$offset+= $temp['length']; $offset+= $temp['length'];
@ -493,7 +493,7 @@ abstract class ASN1
break; break;
case self::TYPE_UTC_TIME: case self::TYPE_UTC_TIME:
case self::TYPE_GENERALIZED_TIME: case self::TYPE_GENERALIZED_TIME:
$current['content'] = self::_decodeTime(substr($content, $content_pos), $tag); $current['content'] = self::decodeTime(substr($content, $content_pos), $tag);
default: default:
} }
@ -516,7 +516,7 @@ abstract class ASN1
* @return array * @return array
* @access public * @access public
*/ */
static function asn1map($decoded, $mapping, $special = []) public static function asn1map($decoded, $mapping, $special = [])
{ {
if (isset($mapping['explicit']) && is_array($decoded['content'])) { if (isset($mapping['explicit']) && is_array($decoded['content'])) {
$decoded = $decoded['content'][0]; $decoded = $decoded['content'][0];
@ -736,7 +736,7 @@ abstract class ASN1
case self::TYPE_UTC_TIME: case self::TYPE_UTC_TIME:
case self::TYPE_GENERALIZED_TIME: case self::TYPE_GENERALIZED_TIME:
if (isset($mapping['implicit'])) { if (isset($mapping['implicit'])) {
$decoded['content'] = self::_decodeTime($decoded['content'], $decoded['type']); $decoded['content'] = self::decodeTime($decoded['content'], $decoded['type']);
} }
return @date(self::$format, $decoded['content']); return @date(self::$format, $decoded['content']);
case self::TYPE_BIT_STRING: case self::TYPE_BIT_STRING:
@ -816,10 +816,10 @@ abstract class ASN1
* @return string * @return string
* @access public * @access public
*/ */
static function encodeDER($source, $mapping, $special = []) public static function encodeDER($source, $mapping, $special = [])
{ {
self::$location = []; self::$location = [];
return self::_encode_der($source, $mapping, null, $special); return self::encode_der($source, $mapping, null, $special);
} }
/** /**
@ -832,7 +832,7 @@ abstract class ASN1
* @throws \RuntimeException if the input has an error in it * @throws \RuntimeException if the input has an error in it
* @access private * @access private
*/ */
static function _encode_der($source, $mapping, $idx = null, $special = []) private static function encode_der($source, $mapping, $idx = null, $special = [])
{ {
if ($source instanceof Element) { if ($source instanceof Element) {
return $source->element; return $source->element;
@ -863,7 +863,7 @@ abstract class ASN1
$child = $mapping['children']; $child = $mapping['children'];
foreach ($source as $content) { foreach ($source as $content) {
$temp = self::_encode_der($content, $child, null, $special); $temp = self::encode_der($content, $child, null, $special);
if ($temp === false) { if ($temp === false) {
return false; return false;
} }
@ -890,7 +890,7 @@ abstract class ASN1
continue; continue;
} }
$temp = self::_encode_der($source[$key], $child, $key, $special); $temp = self::encode_der($source[$key], $child, $key, $special);
if ($temp === false) { if ($temp === false) {
return false; return false;
} }
@ -931,7 +931,7 @@ abstract class ASN1
continue; continue;
} }
$temp = self::_encode_der($source[$key], $child, $key, $special); $temp = self::encode_der($source[$key], $child, $key, $special);
if ($temp === false) { if ($temp === false) {
return false; return false;
} }
@ -1063,19 +1063,19 @@ abstract class ASN1
switch (true) { switch (true) {
case !isset($source): case !isset($source):
return self::_encode_der(null, ['type' => self::TYPE_NULL] + $mapping, null, $special); return self::encode_der(null, ['type' => self::TYPE_NULL] + $mapping, null, $special);
case is_int($source): case is_int($source):
case $source instanceof BigInteger: case $source instanceof BigInteger:
return self::_encode_der($source, ['type' => self::TYPE_INTEGER] + $mapping, null, $special); return self::encode_der($source, ['type' => self::TYPE_INTEGER] + $mapping, null, $special);
case is_float($source): case is_float($source):
return self::_encode_der($source, ['type' => self::TYPE_REAL] + $mapping, null, $special); return self::encode_der($source, ['type' => self::TYPE_REAL] + $mapping, null, $special);
case is_bool($source): case is_bool($source):
return self::_encode_der($source, ['type' => self::TYPE_BOOLEAN] + $mapping, null, $special); return self::encode_der($source, ['type' => self::TYPE_BOOLEAN] + $mapping, null, $special);
case is_array($source) && count($source) == 1: case is_array($source) && count($source) == 1:
$typename = implode('', array_keys($source)); $typename = implode('', array_keys($source));
$outtype = array_search($typename, self::ANY_MAP, true); $outtype = array_search($typename, self::ANY_MAP, true);
if ($outtype !== false) { if ($outtype !== false) {
return self::_encode_der($source[$typename], ['type' => $outtype] + $mapping, null, $special); return self::encode_der($source[$typename], ['type' => $outtype] + $mapping, null, $special);
} }
} }
@ -1090,7 +1090,7 @@ abstract class ASN1
if ($filters === false) { if ($filters === false) {
throw new \RuntimeException('No filters defined for ' . implode('/', $loc)); throw new \RuntimeException('No filters defined for ' . implode('/', $loc));
} }
return self::_encode_der($source, $filters + $mapping, null, $special); return self::encode_der($source, $filters + $mapping, null, $special);
case self::TYPE_NULL: case self::TYPE_NULL:
$value = ''; $value = '';
break; break;
@ -1140,7 +1140,7 @@ abstract class ASN1
* @param int $tag * @param int $tag
* @return string * @return string
*/ */
static function _decodeTime($content, $tag) private static function decodeTime($content, $tag)
{ {
/* UTCTime: /* UTCTime:
http://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 http://tools.ietf.org/html/rfc5280#section-4.1.2.5.1
@ -1187,7 +1187,7 @@ abstract class ASN1
* @access public * @access public
* @param string $format * @param string $format
*/ */
static function setTimeFormat($format) public static function setTimeFormat($format)
{ {
self::$format = $format; self::$format = $format;
} }
@ -1201,7 +1201,7 @@ abstract class ASN1
* @access public * @access public
* @param array $oids * @param array $oids
*/ */
static function loadOIDs($oids) public static function loadOIDs($oids)
{ {
self::$oids+= $oids; self::$oids+= $oids;
self::$reverseOIDs = array_flip(self::$oids); self::$reverseOIDs = array_flip(self::$oids);
@ -1216,7 +1216,7 @@ abstract class ASN1
* @access public * @access public
* @param array $filters * @param array $filters
*/ */
static function setFilters($filters) public static function setFilters($filters)
{ {
self::$filters = $filters; self::$filters = $filters;
} }
@ -1233,7 +1233,7 @@ abstract class ASN1
* @return string * @return string
* @access public * @access public
*/ */
static function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING) public static function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING)
{ {
// isset(self::STRING_TYPE_SIZE[$from] returns a fatal error on PHP 5.6 // isset(self::STRING_TYPE_SIZE[$from] returns a fatal error on PHP 5.6
if (!array_key_exists($from, self::STRING_TYPE_SIZE) || !array_key_exists($to, self::STRING_TYPE_SIZE)) { if (!array_key_exists($from, self::STRING_TYPE_SIZE) || !array_key_exists($to, self::STRING_TYPE_SIZE)) {
@ -1328,7 +1328,7 @@ abstract class ASN1
* @param string $str * @param string $str
* @return string * @return string
*/ */
static function extractBER($str) public static function extractBER($str)
{ {
/* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them
* above and beyond the ceritificate. * above and beyond the ceritificate.
@ -1358,7 +1358,7 @@ abstract class ASN1
* @param string $string * @param string $string
* @return int * @return int
*/ */
static function decodeLength(&$string) public static function decodeLength(&$string)
{ {
$length = ord(Strings::shift($string)); $length = ord(Strings::shift($string));
if ($length & 0x80) { // definite length, long form if ($length & 0x80) { // definite length, long form
@ -1379,7 +1379,7 @@ abstract class ASN1
* @param int $length * @param int $length
* @return string * @return string
*/ */
static function encodeLength($length) public static function encodeLength($length)
{ {
if ($length <= 0x7F) { if ($length <= 0x7F) {
return chr($length); return chr($length);

View File

@ -33,7 +33,7 @@ class Element
* @var string * @var string
* @access private * @access private
*/ */
var $element; public $element;
/** /**
* Constructor * Constructor
@ -42,7 +42,7 @@ class Element
* @return \phpseclib\File\ASN1\Element * @return \phpseclib\File\ASN1\Element
* @access public * @access public
*/ */
function __construct($encoded) public function __construct($encoded)
{ {
$this->element = $encoded; $this->element = $encoded;
} }

File diff suppressed because it is too large Load Diff