mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-17 02:35:10 +00:00
Merge pull request #201 from mpscholten/php5-ssh2-microtime
Replaced php4 hack for microtime(true) with real microtime(true) * mpscholten/php5-ssh2-microtime: Replaced php4 hack for microtime(true) with real microtime(true)
This commit is contained in:
commit
d696f22b89
@ -774,7 +774,7 @@ class Net_SSH2
|
||||
require_once('Crypt/Hash.php');
|
||||
}
|
||||
|
||||
$this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5
|
||||
$this->last_packet = microtime(true);
|
||||
$this->message_numbers = array(
|
||||
1 => 'NET_SSH2_MSG_DISCONNECT',
|
||||
2 => 'NET_SSH2_MSG_IGNORE',
|
||||
@ -845,13 +845,13 @@ class Net_SSH2
|
||||
61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE')
|
||||
);
|
||||
|
||||
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
|
||||
$start = microtime(true);
|
||||
$this->fsock = @fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||
if (!$this->fsock) {
|
||||
user_error(rtrim("Cannot connect to $host. Error $errno. $errstr"));
|
||||
return;
|
||||
}
|
||||
$elapsed = strtok(microtime(), ' ') + strtok('') - $start;
|
||||
$elapsed = microtime(true) - $start;
|
||||
|
||||
$timeout-= $elapsed;
|
||||
|
||||
@ -2497,7 +2497,7 @@ class Net_SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
|
||||
$start = microtime(true);
|
||||
$raw = fread($this->fsock, $this->decrypt_block_size);
|
||||
|
||||
if (!strlen($raw)) {
|
||||
@ -2530,7 +2530,7 @@ class Net_SSH2
|
||||
$buffer.= $temp;
|
||||
$remaining_length-= strlen($temp);
|
||||
}
|
||||
$stop = strtok(microtime(), ' ') + strtok('');
|
||||
$stop = microtime(true);
|
||||
if (strlen($buffer)) {
|
||||
$raw.= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer;
|
||||
}
|
||||
@ -2553,7 +2553,7 @@ class Net_SSH2
|
||||
$this->get_seq_no++;
|
||||
|
||||
if (defined('NET_SSH2_LOGGING')) {
|
||||
$current = strtok(microtime(), ' ') + strtok('');
|
||||
$current = microtime(true);
|
||||
$message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')';
|
||||
$message_number = '<- ' . $message_number .
|
||||
' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)';
|
||||
@ -2724,7 +2724,7 @@ class Net_SSH2
|
||||
$read = array($this->fsock);
|
||||
$write = $except = null;
|
||||
|
||||
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
|
||||
$start = microtime(true);
|
||||
$sec = floor($this->curTimeout);
|
||||
$usec = 1000000 * ($this->curTimeout - $sec);
|
||||
// on windows this returns a "Warning: Invalid CRT parameters detected" error
|
||||
@ -2732,7 +2732,7 @@ class Net_SSH2
|
||||
$this->is_timeout = true;
|
||||
return true;
|
||||
}
|
||||
$elapsed = strtok(microtime(), ' ') + strtok('') - $start;
|
||||
$elapsed = microtime(true) - $start;
|
||||
$this->curTimeout-= $elapsed;
|
||||
}
|
||||
|
||||
@ -2939,12 +2939,12 @@ class Net_SSH2
|
||||
|
||||
$packet.= $hmac;
|
||||
|
||||
$start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
|
||||
$start = microtime(true);
|
||||
$result = strlen($packet) == fputs($this->fsock, $packet);
|
||||
$stop = strtok(microtime(), ' ') + strtok('');
|
||||
$stop = microtime(true);
|
||||
|
||||
if (defined('NET_SSH2_LOGGING')) {
|
||||
$current = strtok(microtime(), ' ') + strtok('');
|
||||
$current = microtime(true);
|
||||
$message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')';
|
||||
$message_number = '-> ' . $message_number .
|
||||
' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)';
|
||||
|
Loading…
Reference in New Issue
Block a user