lib/Touki/FTP/Connection/Connection.php
public function open()
    {
        if ($this->isConnected()) {
            throw new ConnectionEstablishedException;
        }

        $stream = $this->doConnect();

        if (false === $stream) {
            throw new ConnectionException(sprintf("Could not connect to server %s:%s", $this->getHost(), $this->getPort()));
        }

        if (!@ftp_login($stream, $this->getUsername(), $this->getPassword())) {
            throw new ConnectionException(sprintf(
                "Could not login using combination of username (%s) and password (%s)",
                $this->getUsername(),
                preg_replace("/./", "*", $this->getPassword())
            ));
        }

        if (true === $this->passive) {
            if (false === ftp_pasv($stream, true)) {
                throw new ConnectionException("Cold not turn on passive mode");
            }
        }

        $this->connected = true;
        $this->stream    = $stream;

        return true;
    }
public function open()
    {
        if ($this->isConnected()) {
            throw new ConnectionEstablishedException;
        }

        $stream = $this->doConnect();

        if (false === $stream) {
            throw new ConnectionException(sprintf("Could not connect to server %s:%s", $this->getHost(), $this->getPort()));
        }

        if (!@ftp_login($stream, $this->getUsername(), $this->getPassword())) {
            throw new ConnectionException(sprintf(
                "Could not login using combination of username (%s) and password (%s)",
                $this->getUsername(),
                preg_replace("/./", "*", $this->getPassword())
            ));
        }

        if (true === $this->passive) {
            if (false === ftp_pasv($stream, true)) {
                throw new ConnectionException("Cold not turn on passive mode");
            }
        }

        $this->connected = true;
        $this->stream    = $stream;

        return true;
    }
public function open ( ) { if ( $ this -> isConnected ( ) ) { throw new ConnectionEstablishedException ; } $ stream = $ this -> doConnect ( ) ; if ( false === $ stream ) { throw new ConnectionException ( sprintf ( "Could not connect to server %s:%s" , $ this -> getHost ( ) , $ this -> getPort ( ) ) ) ; } if ( ! @ ftp_login ( $ stream , $ this -> getUsername ( ) , $ this -> getPassword ( ) ) ) { throw new ConnectionException ( sprintf ( "Could not login using combination of username (%s) and password (%s)" , $ this -> getUsername ( ) , preg_replace ( "/./" , "*" , $ this -> getPassword ( ) ) ) ) ; } if ( true === $ this -> passive ) { if ( false === ftp_pasv ( $ stream , true ) ) { throw new ConnectionException ( "Cold not turn on passive mode" ) ; } } $ this -> connected = true ; $ this -> stream = $ stream ; return true ; }
Opens the connection

@return boolean TRUE when connection suceeded

@throws ConnectionEstablishedException When connection is already running
@throws ConnectionException            When connection to server failed
@throws ConnectionException            When loging-in to server failed
Opens the connection