ftp_sockets::_data_read()publicWP 1.0

Method of the class: ftp_sockets{}

No Hooks.

Return

null. Nothing (null).

Usage

$ftp_sockets = new ftp_sockets();
$ftp_sockets->_data_read( $mode, $fp );
$mode **
-
Default: FTP_ASCII
$fp **
-
Default: NULL

ftp_sockets::_data_read() code WP 6.5.2

function _data_read($mode=FTP_ASCII, $fp=NULL) {
	$NewLine=$this->_eol_code[$this->OS_local];
	if(is_resource($fp)) $out=0;
	else $out="";
	if(!$this->_passive) {
		$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
		$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
		if($this->_ftp_temp_sock===FALSE) {
			$this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
			$this->_data_close();
			return FALSE;
		}
	}

	while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) {
		if($block==="") break;
		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
		if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
		else $out.=$block;
	}
	return $out;
}