_readmsg example

if(!$this->_ready) {
            $this->PushError($fnction,'Connect first');
            return FALSE;
        }
        if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
        $status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
        if($status===false) {
            $this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
            return FALSE;
        }
        $this->_lastaction=time();
        if(!$this->_readmsg($fnction)) return FALSE;
        return TRUE;
    }

    function _data_prepare($mode=FTP_ASCII) {
        if(!$this->_settype($mode)) return FALSE;
        $this->SendMSG("Creating data socket");
        $this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($this->_ftp_data_sock < 0) {
            $this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock)));
            return FALSE;
        }
        
if(!empty($server)) {
            if(!$this->SetServer($server)) return false;
        }
        if($this->_ready) return true;
        $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
        if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
            $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
            return FALSE;
        }
        $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
        do {
            if(!$this->_readmsg()) return FALSE;
            if(!$this->_checkCode()) return FALSE;
            $this->_lastaction=time();
        } while($this->_code<200);
        $this->_ready=true;
        $syst=$this->systype();
        if(!$syst) $this->SendMSG("Cannot detect remote OS");
        else {
            if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows;
            elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac;
            elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix;
            else $this->OS_remote=FTP_OS_Mac;
            
if(!$this->_ready) {
            $this->PushError($fnction,'Connect first');
            return FALSE;
        }
        if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
        $status=@fputs($this->_ftp_control_sock, $cmd.CRLF);
        if($status===false) {
            $this->PushError($fnction,'socket write failed');
            return FALSE;
        }
        $this->_lastaction=time();
        if(!$this->_readmsg($fnction)) return FALSE;
        return TRUE;
    }

    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()) {
                
Home | Imprint | This part of the site doesn't use cookies.