ftp类(myftp.php)_PHP教程

WBOY
发布: 2016-07-21 16:10:14
原创
1011 人浏览过



class myftp {

    var $connector;
    var $getback;

    function connect($ftp_server, $uname, $passwd){
    // Baut grundlegende FTP Connection auf
        $this->connector = @ftp_connect($ftp_server);
        $this->login_result = @ftp_login($this->connector, "$uname", "$passwd");
        if ((!$this->connector)
(!$this->login_result))
        {
                echo "FTP connection has failed! \n";
                echo "Attempted to connect to $ftp_server for user $uname \n";
                die;
            } else {
                echo "Connected to $ftp_server, for user $uname \n";
            }
    }

    function lastmodtime($value){
        $getback = ftp_mdtm ($this->connector,$value);
        return $getback;
    }

    function changedir($targetdir){
        $getback = ftp_chdir($this->connector, $targetdir);
        return $getback;
    }
    function getdir(){    
        $getback = ftp_pwd($this->connector);
        return $getback;
    }

    function get_file_list($directory){    
        $getback = ftp_nlist($this->connector, $directory);
        return $getback;
    }

    function get_file($file_to_get, $mode, $mode2){
        $realfile = basename($file_to_get);
        $filename = $realfile;

        $checkdir = @$this->changedir($realfile);
        if ($checkdir == TRUE){
            ftp_cdup($this->connector);
            echo "\n[DIR] $realfile";
        }else{
            echo "..... ". $realfile ."\n";
            $getback = ftp_get($this->connector, $filename, $realfile, $mode);
            if ($mode2){
                $delstatus = ftp_delete($this->connector, $file_to_get);
                if ($delstatus == TRUE){
                    echo "File $realfile on $host deleted \n";
                }
            }
        }
        return $getback;
    }

    function mode($pasvmode){
        $result = ftp_pasv($this->connector, $pasvmode);
    }

    function ftp_bye(){
        ftp_quit($this->connector);
        return $getback;
    }
}

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/314323.htmlTechArticle?php class myftp { var $connector; var $getback; function connect($ftp_server, $uname, $passwd){ // Baut grundlegende FTP Connection auf $this-connector = @ftp_connect($ftp_server)...
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!