⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileman.php

📁 网络硬盘_支持1GB文件上传和续传_无错版
💻 PHP
📖 第 1 页 / 共 3 页
字号:
       flush();
       $sizeP=$size/$totalsizes;
       $sizeP=sprintf("%01.2f",$sizeP);
       $sizeP=100*$sizeP;
       if($sizeP<=99)
       {
       echo <<<EOF
<script>advanceProgBarProgress('progBar', 'progBarInner', '$sizeP', '$sizeP%($size/$totalsizes bytes)');</script>
EOF;
       }
       else
       {
       echo <<<EOF
<script>advanceProgBarProgress('progBar', 'progBarInner', '$sizeP', 'Copy Completed!');</script>
EOF;
       }
    }
    /**
    $action
    -----------
    copy to another dir
    delete all files in all dirs
    delete all empty dirs
    chmod special files,such as .php,.pl,.cgi
    copy special files,such as .php,.pl,.cgi
    delete special files,such as .php,.pl,.cgi
    caculate file and subdir numbers in dir
    -----------
    $action
    */
    function _LocalProcessor()
    {
    //init...
    $info=array();
    $info[1][0]=$this->sDir;
    $info[1][1]="?/none";
    $info[1]['index']=1;
    $nextdir=$this->sDir;
    $level=1; $i=0;
    
    //$basedir=dirname($this->sDir);
    $basedir=($this->sDir);

    /*if((!$dir=opendir($this->dDir))&&($this->action=="copy"))
    {
        //$this->SetError("目标文件夹 ".$this->dDir." 不存在!");return 0;
    }*/
    
    while($level!=0){
      $curdir=$nextdir;
      if(!$dir=@opendir($nextdir))
      {
          $this->SetError("can not open directory:$nextdir!!");
          return 0;
      }
      
      $this->debug("Open dir:$nextdir");

      if($basedir!="/")
      {
          $realpath=substr($nextdir,strlen($basedir)+1);
      }
	  else
      {
          $realpath=$nextdir;
      }
      if($this->dDir)
      {
          $destdir=$this->dDir."/".$realpath;
      }
      else
      {
          $destdir=$realpath;
      }
      //=======action:begin========
      if($this->action=='view')
      {
          $list[$i]['name']=$nextdir;
          $list[$i]['folder']=1;
      }
      if($this->action=="copy")
      {
          if(@mkdir($destdir,0777))
          {
              $this->debug("$this->action::$destdir");
          }
          else
          {
              $this->SetError("$this->action::can not create $destdir,continue...");
          }
      }
	  if($this->action=="chmod"||$this->action=="chmoddir")
      {
          if(@chmod($nextdir,$this->permsValue))
          {
              $this->debug("$this->action:$nextdir=>$this->permsValue");
          }
          else
          {
              $this->SetError("Error of $this->action:$nextdir=>$this->permsValue") ;
          }
      }
      if($this->action=="remoteupload")
      {
          if(@ftp_mkdir($this->ftpconn,$destdir))
          {
              $this->debug("$this->action :: create->$destdir");
          }
          else
          {
              $this->SetError("Error of $this->action: create $destdir,continue...");
          }
      }
      //========action:end=========
      $hasdir=0;
      $dirnum=0;

      while($file=readdir($dir)){

         if (($file != ".") && ($file != "..")){
            if(is_dir($nextdir."/".$file)){
              $hasdir=1;
              $info[$level+1][$dirnum]=$nextdir."/".$file;
              $info[$level+1]['index']=0;
              $dirnum++;
              $this->dirnums++;
           }
           if(is_file($nextdir."/".$file)){

              $this->filenums++;
              $this->totalsize=$this->totalsize+filesize($nextdir."/".$file);
              //============action::begin=================
              $i++;
              if($this->action=='view'){
                  $list[$i]['name']="$nextdir/$file";
                  $list[$i]['folder']=0;
              }
              if($this->action=='getfiles'){
                  $this->files[$i]['name']="$nextdir/$file";
                  $this->files[$i]['folder']=0;
              }
              if($this->action=="copy"){
                  if($this->ext=="all"||@in_array($this->fileext($file),$this->ext)){
                      if(@copy($nextdir."/".$file,$destdir."/".$file)){
                          $this->debug("copy $nextdir$file => $destdir$file ");
                      }else{
                          $this->SetError("Err:copy $nextdir$file => $destdir$file ");
                      }
                  }
              }
              if($this->action=="rename"){
                  if($this->ext=="all"||@in_array($this->fileext($file),$this->ext)){
                      $newfile=substr($file,0,strlen($file)-strlen($this->fileext($file))).$this->newext;
                      if(@rename($nextdir."/".$file,$nextdir."/".$newfile)){
                          $this->debug("rename $nextdir$file => $nextdir$newfile ");
                      }
                      else{
                          $this->SetError("Error->rename $nextdir$file => $nextdir$newfile ");
                      }
                  }
              }
              if($this->action=="delfile"){
                  if($this->ext=="all"||@in_array($this->fileext($file),$this->ext)){
                      if(unlink($nextdir."/".$file))
                           $this->debug("delete file:".$nextdir.$file);
                      else
                           $this->SetError("Err:delete file:".$nextdir.$file);
                  }
              }
              if($this->action=="remoteupload"){
                  if(@in_array($this->fileext($file),$this->ext)||$this->ext=='all'){
                    if(@ftp_put($this->ftpconn,$destdir."/".$file,$nextdir."/".$file,$this->ftpAsciiBinary($file)))
                    {
                       $this->debug("ftp put files:".$nextdir."/".$file." to ".$destdir."".$file);
                       $this->echoBar($this->totalsize,$this->filenums,$this->dirnums);
                    }
                    else
                       $this->SetError("Error of put files:".$nextdir."/".$file." to ".$destdir.$file);
                  }
              }
			   if($this->action=="chmod"||$this->action=="chmodfile"){
                   if(@in_array($this->fileext($file),$this->ext)||$exinfo[ext]=='all'){
                      if(@chmod($nextdir."/". $file,$this->permsValue))
                         $this->debug("chmod:".$nextdir."/".$file."=>".$this->permsValue);
                      else
                         $this->SetError("Error->chmod:".$nextdir."/".$file."=>".$this->permsValue);
                   }
              }
              //===============action:end=====================
           }
         }

      }//end read dir while
      $i++;
      closedir($dir);
      $noindex=$info[$level+1]['index']+1;
      $info[$level+1][$dirnum]="?/none";

      if($hasdir==1){//level+1下一层次,即下一个兄弟接点是否存在
          $curindex=$info[$level+1]['index'];
          $nextdir= $info[$level+1][$curindex];
          $info[$level+1]["index"]++;
          $level++;
      }
      else{
          if($this->action=="deldir"){
             if(@rmdir($nextdir)) $this->debug( "delete dir:".$nextdir );
             else  $this->SetError( "Error->delete dir:".$nextdir );
          }
          if($this->action=='getfiles'){
             $this->files[$i]['name']="$nextdir";
             $this->files[$i]['folder']=1;
          }
          $tempflag=0;
          while($level!=0 && $tempflag==0){

               $curindex=$info[$level]['index'];
               if($info[$level][$curindex]!="?/none") {
                    $nextdir=$info[$level][$curindex];
                    $info[$level]['index']++;
                    $tempflag=1;
               }
               else{
                    $level--;
                    if($this->action=="deldir"){
                        $curindex= $info[$level]["index"];
                        $deldir= $info[$level][$curindex-1];
                        if($deldir){
                           if(@rmdir($deldir)) $this->debug("delete dir:".$deldir);
                           else $this->SetError("Err:delete dir:".$deldir);
                        }
                    }
                    if($this->action=='getfiles'){
                        $curindex= $info[$level]["index"];
                        $deldir= $info[$level][$curindex-1];
                        $this->files[$i]['name']=$deldir;
                        $this->files[$i]['folder']=1;
                    }
                    //echo "--->level:".$level."<br>";
               } //end if
          }//end goback while
      }//end if

    }//end level while

    $this->dirnums++;

    $this->debug("文件夹: $this->dirnums 个;文件: $this->filenums 个.Size:$this->totalsize bytes");

    if($this->action=='view') return $list;

    }//end func
    /**
    $action
    copy to another dir
    delete all files in all dirs
    delete all empty dirs
    chmod special files,such as .php,.pl,.cgi
    copy special files,such as .php,.pl,.cgi
    delete special files,such as .php,.pl,.cgi
    caculate file and subdir numbers in dir
    $action
    */
    function _FTPProcessor()
    {
    //init...
    $info=array();
    $info[1][0]=$this->sDir;
    $info[1][1]="?/none";
    $info[1]['index']=1;
    $nextdir=$info[1][0];
    $level=1;$deldirs=$i=0;
    
    $basedir=dirname($this->sDir);
    $basedir=($this->sDir);

       
    if($this->action=="download")
    {
        if(!$dir=opendir($this->dDir))
        {
           $this->SetError("target directory  ".$targetdir["dest"]." doesn't exist!");
           return 0;
        }
    }

    while($level!=0){

      if($this->action=="view"){
          $list[$i][name]= $nextdir;
          $list[$i][folder]=1;
      }
      //$files = ftp_nlist($this->ftpconn,$nextdir);
      $files = $this->ftp_getlist($this->ftpconn,$nextdir);

      $this->debug("Get list from $nextdir");
      $hasdir=0;
      $dirnum=0;

	  if($basedir=="")  $realpath=$nextdir;
	  else $realpath=substr($nextdir,strlen($basedir)+1);
      $destdir=$this->dDir."/".$realpath;

      //=====action::begin=============
      if($this->action=="download"){
          if(@mkdir($destdir,0755))
          $this->debug("$this->action-> mkdir:".$destdir);
          else
          $this->SetError("error of $this->action mkdir:".$destdir);
      }
      if($this->action=="chmod"||$this->action=="chmoddir"){
          if(function_exists('ftp_chmod')&&ftp_chmod($this->ftpconn, $this->permsValue, $nextdir))
          $this->debug("chmod: $nextdir => $this->permsValue");
          elseif(function_exists('ftp_site')&&ftp_site($this->ftpconn, "CHMOD $this->permsValue $nextdir"))
          $this->debug("chmod: $nextdir => $this->permsValue");
          else
          $this->SetError("fail to chmod: $nextdir => $this->permsValue");
      }
      //======action:end============

      if($files)
      foreach ($files as $key=>$fileinfo) {
          $isdir=$fileinfo[dirorfile];
          $file=$fileinfo[dirfilename];
          if (($file != ".") && ($file != "..")){
          if($isdir == "d") { //Is a directory
             $hasdir=1;
             $info[$level+1][$dirnum]=$nextdir.'/'.$file;
             $info[$level+1]['index']=0;
             $dirnum++;
             $this->dirnums++;
          }
          if($isdir == "-") { //Is a file
             $this->filenums++;
             $i++;
             //=====action::begin================
             if($this->action=="view"){
                $list[$i][name]= $nextdir.'/'.$file;
                $list[$i][folder]=0;
             }
             if($this->action=='getfiles'){
                  $this->files[$i]['name']="$nextdir/$file";
                  $this->files[$i]['folder']=0;
             }
             if($this->action=="delfile"){
                 if(@in_array($this->fileext($file),$this->ext)||$this->ext=='all'){
                  if(ftp_delete($this->ftpconn, $nextdir.'/'.$file))  $this->debug("delete: $file");
                  else   $this->SetError("Error->delete: $file");
                 }
             }
             if($this->action=="rename"){
                 if(@in_array($this->fileext($file),$this->ext)||$this->ext=='all'){
                 // if(ftp_delete($this->ftpconn, $nextdir.'/'.$file))  $this->debug("delete: $file");
                 // else   $this->SetError("Error->delete: $file");
                 //}
                 $newfile=substr($file,0,strlen($file)-strlen($this->fileext($file))).$this->newext;
                 if(@ftp_rename($this->ftpconn,$nextdir."/".$file,$nextdir."/".$newfile)){
                    $this->debug("rename $nextdir$file => $destdir$newfile ");
                 }
                 else{
                    $this->SetError("Error->rename $nextdir$file => $destdir$newfile ");
                 }
                 }
             }
		     if($this->action=="chmod"||$this->action=="chmodfiles"){
                 if(@in_array($this->fileext($file),$this->ext)||$this->ext=='all'){
                     if(function_exists('ftp_chmod')&&ftp_chmod($this->ftpconn, $this->permsValue, $nextdir.'/'.$file))
                        $this->debug("chmod: $nextdir/$file => $this->permsValue");
                     elseif(function_exists('ftp_site')&&ftp_site($this->ftpconn, "CHMOD $this->permsValue $nextdir/$file"))
                        $this->debug("chmod: $nextdir/$file=>$this->permsValue");
                     else
                        $this->SetError("Error->chmod: $nextdir/$file=>$this->permsValue");
                 }
             }
             if($this->action=="download"){
                 if(@in_array($this->fileext($file),$this->ext)||$this->ext=='all'){
                     if(ftp_get($this->ftpconn,$destdir."/".$file,$nextdir.'/'.$file,$this->ftpAsciiBinary($file)) )
                        $this->debug("download files:".$nextdir.'/'.$file." -> ".$destdir."/".$file);
                     else
                        $this->SetError("error of download files:".$nextdir.'/'.$file." -> ".$destdir."/".$file);
                 }
             }
             //=======action:end================
          }
          $this->totalsize=$this->totalsize+$fileinfo[size];
        }
      }
      $i++;
      $info[$level+1][$dirnum]="?/none";

      if($hasdir==1){//level+1下一层次,即下一个兄弟接点是否存在
          $curindex=$info[$level+1]['index'];
          $nextdir= $info[$level+1][$curindex];
          $info[$level+1]["index"]++;
          $level++;
      }
      else{
          if($action=="deldir"){
             if(@ftp_rmdir($this->ftpconn,$nextdir))
                 $this->debug( "delete dir::".$nextdir);
             else
                 $this->SetError( "error of delete dir::".$nextdir);
             $deldirs++;
             if($this->action=='getfiles'){
                 $this->files[$i]['name']=$nextdir;
                 $this->files[$i]['folder']=1;
             }
          }
          $tempflag=0;
          while($level!=0 && $tempflag==0){
               //echo "curdir:".$curdir."<br>";
               $curindex=$info[$level]['index'];
               //echo "level:".$level."  curindex=:".$curindex."<br>";
               if($info[$level][$curindex]!="?/none") {
                    $nextdir=$info[$level][$curindex];
                    $info[$level]['index']++;
                    $tempflag=1;
                    //goto 1:
               }
               else{
                    $level--;
                    if($this->action=="deldir"){
                        $curindex= $info[$level]["index"];
                        $deldir= $info[$level][$curindex-1];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -