商業源碼熱門下載www.html.org.cn
這個類不安全,需要修改
<?php
/**
*httpdownload
*
*@author sanshi
qq:35047205
email:[email protected]
msn:[email protected]
*
*@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>聯系方式:[email protected]</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();
?>
新聞熱點
疑難解答