';
}
}
$ftp=new ftp;
$ftp->init($HOST,$USER,$PASS);
$s=$ftp->pwd();
$ftp->close();
ftpurl($s,0,1,'URL1'); //$s may be need to change
?>
[/HTML]
以下为类文件
[HTML]
class ftp
{
var $id,$tid,$HOST,$USER,$PASS,$pwd;
var $china_mulu;
function init($HOST,$USER,$PASS)
{
$this->HOST=$HOST;
$this->USER=$USER;
$this->PASS=$PASS;
$this->setup();
}
function setup()
{
if($this->HOST=='')$this->HOST='localhost';
if($this->USER=='')$this->USER='';
if($this->PASS=='')$this->PASS='';
$this->id=ftp_connect($this->HOST) or $this->ftp_msg("can not connect ftp");
$this->tid=ftp_login($this->id,$this->USER,$this->PASS) or $this->ftp_msg("can not open it");
}
function pwd()//取得路径
{
$this->pwd=ftp_pwd($this->id);
return $this->pwd;
}
function initpwd($pwd)
{
$this->pwd=$pwd;
}
function mulu()//取得目录
{
if(!$this->pwd)
$this->pwd=ftp_pwd($this->id);
$this->chinamulu=ftp_rawlist($this->id,$this->pwd);
return $this->chinamulu;
}
function upmulu()//返回上级目录
{
$a=ftp_cdup($this->id) or $this->ftp_msg("already be the uppest!!");
}
function close()
{
ftp_quit($this->id);
}
function ftp_msg($err)
{
print"