ftp_pure::_data_prepare()publicWP 1.0

Method of the class: ftp_pure{}

No Hooks.

Return

null. Nothing (null).

Usage

$ftp_pure = new ftp_pure();
$ftp_pure->_data_prepare( $mode );
$mode **
-
Default: FTP_ASCII

ftp_pure::_data_prepare() code WP 6.5.2

function _data_prepare($mode=FTP_ASCII) {
	if(!$this->_settype($mode)) return FALSE;
	if($this->_passive) {
		if(!$this->_exec("PASV", "pasv")) {
			$this->_data_close();
			return FALSE;
		}
		if(!$this->_checkCode()) {
			$this->_data_close();
			return FALSE;
		}
		$ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message));
		$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
            $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
		$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
		$this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
		if(!$this->_ftp_data_sock) {
			$this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")");
			$this->_data_close();
			return FALSE;
		}
		else $this->_ftp_data_sock;
	} else {
		$this->SendMSG("Only passive connections available!");
		return FALSE;
	}
	return TRUE;
}