商业源码热门下载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();
?>
新闻热点
疑难解答