mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-26 19:40:28 +00:00
Merge pull request #215 from terrafrost/preg-replace-callback
SSH2: fix E_DEPRECATED on PHP5.5 * terrafrost/preg-replace-callback: SSH2: fix E_DEPRECATED on PHP5.5
This commit is contained in:
commit
0dc8b27a6a
@ -747,6 +747,30 @@ class Net_SSH2
|
|||||||
*/
|
*/
|
||||||
var $is_timeout = false;
|
var $is_timeout = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log Boundary
|
||||||
|
*
|
||||||
|
* @see Net_SSH2::_format_log
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $log_boundary = ':';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log Long Width
|
||||||
|
*
|
||||||
|
* @see Net_SSH2::_format_log
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $log_long_width = 65;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log Short Width
|
||||||
|
*
|
||||||
|
* @see Net_SSH2::_format_log
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $log_short_width = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
@ -3218,8 +3242,6 @@ class Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function _format_log($message_log, $message_number_log)
|
function _format_log($message_log, $message_number_log)
|
||||||
{
|
{
|
||||||
static $boundary = ':', $long_width = 65, $short_width = 16;
|
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
for ($i = 0; $i < count($message_log); $i++) {
|
for ($i = 0; $i < count($message_log); $i++) {
|
||||||
$output.= $message_number_log[$i] . "\r\n";
|
$output.= $message_number_log[$i] . "\r\n";
|
||||||
@ -3229,19 +3251,13 @@ class Net_SSH2
|
|||||||
if (strlen($current_log)) {
|
if (strlen($current_log)) {
|
||||||
$output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 ';
|
$output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 ';
|
||||||
}
|
}
|
||||||
$fragment = $this->_string_shift($current_log, $short_width);
|
$fragment = $this->_string_shift($current_log, $this->log_short_width);
|
||||||
$hex = substr(
|
$hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary));
|
||||||
preg_replace(
|
|
||||||
'#(.)#es',
|
|
||||||
'"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)',
|
|
||||||
$fragment),
|
|
||||||
strlen($boundary)
|
|
||||||
);
|
|
||||||
// replace non ASCII printable characters with dots
|
// replace non ASCII printable characters with dots
|
||||||
// http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
|
// http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
|
||||||
// also replace < with a . since < messes up the output on web browsers
|
// also replace < with a . since < messes up the output on web browsers
|
||||||
$raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment);
|
$raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment);
|
||||||
$output.= str_pad($hex, $long_width - $short_width, ' ') . $raw . "\r\n";
|
$output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n";
|
||||||
$j++;
|
$j++;
|
||||||
} while (strlen($current_log));
|
} while (strlen($current_log));
|
||||||
$output.= "\r\n";
|
$output.= "\r\n";
|
||||||
@ -3250,6 +3266,20 @@ class Net_SSH2
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for _format_log
|
||||||
|
*
|
||||||
|
* For use with preg_replace_callback()
|
||||||
|
*
|
||||||
|
* @param Array $matches
|
||||||
|
* @access private
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
function _format_log_helper($matches)
|
||||||
|
{
|
||||||
|
return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all errors
|
* Returns all errors
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user