免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1263 | 回复: 0
打印 上一主题 下一主题

一个FTP树状目录(PHP) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-06-21 14:52 |只看该作者 |倒序浏览

结合js做的,具体的话相应要做修改,比如目录制
[HTML]
with (document) {
        write("");
        write(".child {display:none}")
        write("");
    }
function initIt(){
        divColl = document.all.tags("DIV");
        for (i=0; i
10)
      {}
    else
      {
        global $HOST,$USER,$PASS;
        $ftp=new ftp;
        $ftp->init($HOST,$USER,$PASS);
        $ftp->initpwd($url);
        $a=$ftp->mulu();
        $ftp->close();
        $a=hsort($a);
        if($in!=1)
          {
            $sss=$name.'Child';
            echo'';
          }
        $v=0;
        for($i=1;$i';
                        echo''.$aa[$c].'
                             ';
                      }
                    else
                      {
                        $names=$name.'_'.$v;
                        echo'';
                        for($hu=0;$hu';
                        echo''.$aa[$c].'
                             ';
                      }
                    $url1=$url.'/'.$aa[$c];//may be need to change
                    $konge1=$konge+1;
                    ftpurl($url1,$konge1,0,$names);
                  }
              }
            else
              {
                $c=count($aa);
                $c-=1;
                if($in==1)
                  {
                    $name='URL'.$i.'Parent';
                    $name1='URL'.$i;
                    echo'';
                    echo''.$aa[$c].'
                    ';
                  }
                else
                  {
                    echo'';
                    for($hu=0;$hu';
                    echo''.$aa[$c].'
                    ';
                  }
              }
          }
        if($in!=1)
          echo'';
      }
  }
$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]
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"$err";
      }
  }
?>
[/HTML]


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/623/showart_32204.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP