最简易的PHP网盘系统/单位文件下载小功能页面

最简易的PHP网盘系统/单位文件下载小功能页面

遍历目录下的.rar格式文件,显示到网页提供下载

FTP上传压缩包到文件夹下,就可以显示到文件供访问下载。

<?php


/*

 //最简易的PHP网盘系统/单位文件下载小功能页面
 //遍历目录下的.rar格式文件,显示到网页提供下载
 //FTP上传压缩包到文件夹下,就可以显示到文件供访问下载。

*/


error_reporting(0);

header('Content-Type: text/html; charset=utf-8');

?>



<style>

h1{font-size:24px;line-height:180%;font-weight:600;margin:4px 8px;color:red;}

h2,b{font-size:20px;line-height:160%;font-weight:600;margin:3px 6px;color:green;}

h3{font-size:16px;line-height:140%;font-weight:600;margin:2px 4px;color:blue;}

h4{font-size:14px;line-height:120%;font-weight:300;margin:1px 2px;color:black;}



a{text-decoration:none;}

a:link{color:blue;}

a:visited{color:blue;}

a:hover,a:active{background:#0180CF;color:white;}


table{border-left:1px solid #a2c6d3;border-top:3px solid #0180CF; margin:15px auto;}

table{width:88%;min-width:555px;max-width:888px;}

table td{border-right:1px solid #a2c6d3;border-bottom:1px solid #a2c6d3;}

table td{padding:2px;word-wrap:break-word;word-break:break-all;}

.tt{background:#e5f2fa;line-height:18px;FONT-SIZE:12px;text-align:center;}

.rr{background:#e5f2fa;line-height:18px;FONT-SIZE:12px;text-align:center;}



</style>

<?php

function charaget($data){

if(!empty($data) ){

$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;

if( $fileType != 'UTF-8'){

$data = mb_convert_encoding($data ,'utf-8' , $fileType);

}

}

return $data;

}



function characet($data){

if(!empty($data) ){

$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;

if( $fileType != 'GBK'){

$data = mb_convert_encoding($data ,'GBK' , $fileType);

}

}

return $data;

}



function my_scandir($dir){

 $ii=0;

 if ( $handle = opendir($dir) ) {

 while ( ($file = readdir($handle)) !== false ) {

 if ( $file != ".." && $file != "." ) {

 if ( is_dir($dir . $file. "/" ) ) {

 $filep = $dir . $file . "/";

 $filep = charaget($filep); 

 $filea = charaget($file);


 $decho = my_scandir($dir . $file. "/" );



 }else{



 $filep = $dir . $file;

 $filet = substr($file,-4);

 $filep = charaget($filep);

 $filea = charaget($file);


if(stristr("-.rar-.zip-","-{$filet}-")){

$ii++;

$filesize = filesize($filep);

$filetime = date("Y-m-d H:i:s",filectime($filep));

$fileedit = date("Y-m-d H:i:s",filemtime($filep));


if (is_file($filep)){

}else{

}


$fecho.="<tr><td colspan=\"4\"><a href='{$filep}' target='_blank'><h3>{$filea}</h3></a>

</td></tr>";

}else{

//echo "<h4>$file</h4>";

}



 }

 }

 }



 closedir($handle);

if($ii>0){

$iecho = "<tr class=\"rr\"><td colspan=\"4\"><b>{$dir}</b></td></tr>\r\n";

return $iecho . $fecho .$decho ;

}else{

return "<tr><td colspan=\"4\"><h2>文件夹<b>{$dir}</b>下没有文件</h2></td></tr>\r\n";
}

 

 }

} 





echo "<table cellspacing=\"0\" class=\"table\" cellpadding=\"0\">\r\n";



$fd = trim($_GET['f']);

if(strlen($fd)<1){ $fd="./"; }else{ $fd=$fd;}

echo my_scandir($fd);

echo "</table>\r\n";


?>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YUJIANYUE

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值