search
Homephp教程php手册http 协议下载类(自家用)

这个类不安全,需要修改

/**
*HttpDownLoad
*
*@author  sanshi
    QQ:35047205
    Email:sanshi0815@tom.com
    MSN:sanshi0815@tom.com
*
*@version  1.0.0  2005/07/10
*
*@deprecated     
 1.http协议下载
 
*/
class HttpDownLoad
{
 var $rootDom="D:/jsp/";//设定下载目录,需要绝对路径
 var $openDir;           //打开绝对的路径
 var $open;    //将要打开的目录
 var $enter=3;   //设置换行
 var $table_w=800;  //设置表格宽度
 var $div=array();     //设置目录存放数组
 var $file=array();      //设置文件存放数组
 var $link=array();     //设置连接文件数组

 //构造函数
 function HttpDownLoad()
 {
  $this->getAll();
  $this->head();
  $this->printArray($this->dir,"目录");
  $this->printArray($this->file,"文件");
  $this->foot();
 }
 //设置输出标题头
 function head()
 {
  echo "

".
    "".
     "".
      "">sanshi0815@tom.com>".
       "
 
www.litou.com 专用版
作    者: 叁  石
联系方式:
  Q  Q  : 35047205
";
 }
 //设置结束尾
 function foot()
 {

 }
 //取得将要打开的目录
 function getOpen()
 {
  $open=$_GET["dir"];
  $this->open=$open;
  if(!isset($open)||empty($open))
  {
   $openDir=$this->rootDom;
  }else{
   $openDir=$this->rootDom.$open."/";
  }
  $this->openDir=$openDir;
  return $openDir;
 }

 //将目录中的内容进行分档
 function getAll()
 {
  $openDir=$this->getOpen();
  $handle=opendir($openDir);
  while($allFile=readdir($handle))
  {
   if(is_dir($openDir.$allFile))
   {
    $this->dir[]=$allFile;
   }else if(is_file($openDir.$allFile))
   {
    $this->file[]=$allFile;
   }else if(is_link($openDir.$allFile))
   {
    $this->link[]=$allFile;
   }
  }
  closedir($handle);
  //echo count($this->dir)."
";
  //echo count($this->file)."
";
  //echo count($this->link)."
";
 }
 //检查是否为目录
 function isDir($dir)
 {
  if(is_dir($dir))
  {
   return true;
  }
  return false;
 }
 //检查是否为文件
 function isFile($file)
 {
  if(is_file($file))
  {
   return true;
  }
  return false;
 }
 //数组打印
 function printArray($array,$title)
 {
  $j=0;
  if(count($array)>0)
  {
   
   echo "

";
   echo "";
   foreach($array as $v)
   {
    $v=trim($v);
    if(substr($v,0,1)!=".")
    {
     
     if($j%$this->enter==0)
     {
      echo "";
     }
     if(!isset($this->open)||empty($this->open))
     {
      $l="";
     }else{
      $l="/";
     }
     if($this->isDir($this->openDir.$v))
     {
      $url=$PHP_SELF."?dir=".$this->open.$l.$v;
      $color="#FF0033";
      $size="3";
     }else if($this->isFile($this->openDir.$v)){
      $url=$this->openDir.$v;
      $color="#0000FF";
      $size="5";
     }
     $j++;
     echo "";
    }
   }
   
  }
 }

}
?>
$do=new HttpDownLoad();
?>




".$title."".$v."    
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)