這個類不安全,需要修改
<?php
/**
*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 "<table width='".$this->table_w."' align='center'><tr><td height='20%'> </td></tr><tr>".
"<td align='center'><FONT SIZE='8' COLOR=''>www.litou.com 專用版</FONT></td>".
"</tr><tr><td>作 者: 三 石</td></tr>".
"<tr><td>連絡方式:sanshi0815@tom.com</td></tr>".
"<tr><td>  Q Q : 35047205</td></tr></table>";
}
//設定結束尾
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)."<br>";
//echo count($this->file)."<br>";
//echo count($this->link)."<br>";
}
//檢查是否為目錄
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 "<table width='".$this->table_w."' align='center'><tr>";
echo "<td colspan='".$this->enter."'><HR></td></tr><tr>";
foreach($array as $v)
{
$v=trim($v);
if(substr($v,0,1)!=".")
{
if($j%$this->enter==0)
{
echo "</tr><tr>";
}
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 "<td><FONT SIZE='".$size."' COLOR='".$color."'>".$title."</FONT><a href='".$url."'>".$v."</a> </td>";
}
}
}
}
}
?>
<?php
$do=new HttpDownLoad();
?>