SendMSG example

/* Constructor */
    function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
        $this->LocalEcho=$le;
        $this->Verbose=$verb;
        $this->_lastaction=NULL;
        $this->_error_array=array();
        $this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n");
        $this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY);
        $this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS');
        $this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT");
        $this->_port_available=($port_mode==TRUE);
        $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support"));
        $this->_connected=FALSE;
        $this->_ready=FALSE;
        $this->_can_restore=FALSE;
        $this->_code=0;
        $this->_message="";
        $this->_ftp_buff_size=4096;
        $this->_curtype=NULL;
        $this->SetUmask(0022);
        $this->SetType(FTP_AUTOASCII);
        $this->SetTimeout(30);
        $this->Passive(!$this->_port_available);
        
return FALSE;
        }
        if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
            $this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock)));
            @socket_close($sock);
            return FALSE;
        }
        return true;
    }

    function _connect($host$port) {
        $this->SendMSG("Creating socket");
        if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
            $this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
            return FALSE;
        }
        if(!$this->_settimeout($sock)) return FALSE;
        $this->SendMSG("Connecting to \"".$host.":".$port."\"");
        if (!($res = @socket_connect($sock$host$port))) {
            $this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
            @socket_close($sock);
            return FALSE;
        }
        

    function _settimeout($sock) {
        if(!@stream_set_timeout($sock$this->_timeout)) {
            $this->PushError('_settimeout','socket set send timeout');
            $this->_quit();
            return FALSE;
        }
        return TRUE;
    }

    function _connect($host$port) {
        $this->SendMSG("Creating socket");
        $sock = @fsockopen($host$port$errno$errstr$this->_timeout);
        if (!$sock) {
            $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")");
            return FALSE;
        }
        $this->_connected=true;
        return $sock;
    }

    function _readmsg($fnction="_readmsg"){
        if(!$this->_connected) {
            
Home | Imprint | This part of the site doesn't use cookies.