_exec example

$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()) {
                $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);
            
return FALSE;
        }
        $this->_type=$mode;
        $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) );
        return TRUE;
    }

    function _settype($mode=FTP_ASCII) {
        if($this->_ready) {
            if($mode==FTP_BINARY) {
                if($this->_curtype!=FTP_BINARY) {
                    if(!$this->_exec("TYPE I", "SetType")) return FALSE;
                    $this->_curtype=FTP_BINARY;
                }
            } elseif($this->_curtype!=FTP_ASCII) {
                if(!$this->_exec("TYPE A", "SetType")) return FALSE;
                $this->_curtype=FTP_ASCII;
            }
        } else return FALSE;
        return TRUE;
    }

    function Passive($pasv=NULL) {
        
$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(!$this->_settimeout($this->_ftp_data_sock)) {
            $this->_data_close();
            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);
            
Home | Imprint | This part of the site doesn't use cookies.