首页 > 开发 > PHP > 正文

ftp类(myftp.php)

2024-05-04 23:00:09
字体:
来源:转载
供稿:网友
国内最大的酷站演示中心!
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;
}
}

?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表