网络编程 
首页 > 网络编程 > 浏览文章

ftp类(myftp.php)

(编辑:jimmy 日期: 2024/11/16 浏览:3 次 )

<?php

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;
    }
}

?>

上一篇:PHP出错界面
下一篇:第1次亲密接触PHP5(2)
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。