phpseclib\Net\SFTP::_send_sftp_packet PHP Method

_send_sftp_packet() public method

See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info.
See also: self::_get_sftp_packet()
See also: self::_send_channel_packet()
public _send_sftp_packet ( integer $type, string $data ) : boolean
$type integer
$data string
return boolean
    function _send_sftp_packet($type, $data)
    {
        $packet = $this->request_id !== false ? pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : pack('NCa*', strlen($data) + 1, $type, $data);
        $start = strtok(microtime(), ' ') + strtok('');
        // http://php.net/microtime#61838
        $result = $this->_send_channel_packet(self::CHANNEL, $packet);
        $stop = strtok(microtime(), ' ') + strtok('');
        if (defined('NET_SFTP_LOGGING')) {
            $packet_type = '-> ' . $this->packet_types[$type] . ' (' . round($stop - $start, 4) . 's)';
            if (NET_SFTP_LOGGING == self::LOG_REALTIME) {
                echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n";
                flush();
                ob_flush();
            } else {
                $this->packet_type_log[] = $packet_type;
                if (NET_SFTP_LOGGING == self::LOG_COMPLEX) {
                    $this->packet_log[] = $data;
                }
            }
        }
        return $result;
    }