Replaced php4 hack for microtime(true) with real microtime(true)

This commit is contained in:
Marc Philip Scholten 2013-12-05 18:46:46 +01:00
parent 03f290b050
commit d6c70a76d9
1 changed files with 11 additions and 11 deletions

View File

@ -773,7 +773,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',
@ -844,13 +844,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;
@ -2496,7 +2496,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)) {
@ -2529,7 +2529,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;
}
@ -2552,7 +2552,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)';
@ -2723,7 +2723,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
@ -2731,7 +2731,7 @@ class Net_SSH2 {
$this->is_timeout = true;
return true;
}
$elapsed = strtok(microtime(), ' ') + strtok('') - $start;
$elapsed = microtime(true) - $start;
$this->curTimeout-= $elapsed;
}
@ -2938,12 +2938,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)';