ftp_base::SetServer()publicWP 1.0

Метод класса: ftp_base{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ftp_base = new ftp_base();
$ftp_base->SetServer( $host, $port, $reconnect );
$host (обязательный)
-
$port **
-
По умолчанию: 21
$reconnect **
-
По умолчанию: true

Код ftp_base::SetServer() WP 6.4.3

function SetServer($host, $port=21, $reconnect=true) {
	if(!is_long($port)) {
        $this->verbose=true;
    	    $this->SendMSG("Incorrect port syntax");
		return FALSE;
	} else {
		$ip=@gethostbyname($host);
        $dns=@gethostbyaddr($host);
        if(!$ip) $ip=$host;
        if(!$dns) $dns=$host;
        // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
        // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
        $ipaslong = ip2long($ip);
		if ( ($ipaslong == false) || ($ipaslong === -1) ) {
			$this->SendMSG("Wrong host name/address \"".$host."\"");
			return FALSE;
		}
        $this->_host=$ip;
        $this->_fullhost=$dns;
        $this->_port=$port;
        $this->_dataport=$port-1;
	}
	$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
	if($reconnect){
		if($this->_connected) {
			$this->SendMSG("Reconnecting");
			if(!$this->quit(FTP_FORCE)) return FALSE;
			if(!$this->connect()) return FALSE;
		}
	}
	return TRUE;
}