PHP获取Linux当前目录下文件并实现下载功能
使用nginx转发过去给php
server{
listen 9099;
server_name 18.5.6.2;
location / {
proxy_http_version 1.1;
root /opt/zidian/crackPass;
index index.html index.htm index.php;
}
location ~* \.php$ {
root /opt/zidian/crackPass;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/zidian/crackPass$fastcgi_script_name;
include fastcgi_params;
}
}
server_name 公网ip
fastcgi_pass 127.0.0.1:9000 转发给php(使用netstat -tlnp | grep php看到php的端口是9000)
index.php
<?php
#echo "<body style='background:url(o_cheng.jpg)'; backgroundRepeat:'no-repeat'; backgroundPosition='top center'; >";
header("Content-type: text/html; charset=utf-8");
function getsize($size, $format = 'kb') {
$p = 0;
if ($format == 'kb') {
$p = 1;
} elseif ($format == 'mb') {
$p = 2;
} elseif ($format == 'gb') {
$p = 3;
}
$size /= pow(1024, $p);
return number_format($size, 3);
}
function read_all ($dir){
if(!is_dir($dir)) return false; $handle = opendir($dir); if($handle){
while(($fl = readdir($handle)) !== false){
$temp = iconv('utf-8','utf-8',$dir.DIRECTORY_SEPARATOR.$fl);
if(is_dir($temp) && $fl!='.' && $fl != '..'){
#echo '目录:'.$temp.'<br>';
#read_all($temp);
}else{
if($fl!='.' && $fl != '..'){
#echo $fl;
#echo '文件:'.$temp.'<br>';
$cfiletime = filectime($fl);
echo "文件:";
echo "<span style='font-size:6px;'>";
echo "<a href='$fl' download='$fl'>'$fl'";
echo "</a>";
echo "</span>";
$size = filesize($fl);
$size = getsize($size, 'mb');
echo "容量:";
echo "<span style='font-size:6px;'>$size.'M'";
echo "</span>";
# echo "创建时间:";
# echo "<span style='font-size:6px;'>" .date("Y-m-d H:i:s",$cfiletime);
echo "</span>";
echo "<br>";
}
}
}
}
}
read_all('.');
echo "<br/>";
echo "<a href='400W常用密码/index.php'>";
echo "<button>400W常用密码</button>";
echo "</a>";
#echo "</body>";
?>
index.php(2018-06-21)
<?php
#echo "<body style='background:url(o_cheng.jpg)'; backgroundRepeat:'no-repeat'; backgroundPosition='top center'; >";
header("Content-type: text/html; charset=utf-8");
echo "<h3 align='center'>";
echo "夏天分享小知识";
echo "</h3>";
ini_set('date.timezone','Asia/Shanghai');
function getsize($size, $format = 'kb') {
$p = 0;
if ($format == 'kb') {
$p = 1;
} elseif ($format == 'mb') {
$p = 2;
} elseif ($format == 'gb') {
$p = 3;
}
$size /= pow(1024, $p);
return number_format($size, 3);
}
function read_all ($dir){
if(!is_dir($dir)) return false; $handle = opendir($dir); if($handle){
while(($fl = readdir($handle)) !== false){
$temp = iconv('utf-8','utf-8',$dir.DIRECTORY_SEPARATOR.$fl);
if(is_dir($temp) && $fl!='.' && $fl != '..'){
#echo '目录:'.$temp.'<br>';
#read_all($temp);
}else{
if($fl!='.' && $fl != '..'){
#echo $fl;
#echo '文件:'.$temp.'<br>';
$cfiletime = filectime($fl);
echo "<table>";
echo "<td width=400px>";
echo "文件:";
echo "<span style='font-size:6px;'>";
echo "<a href='$fl' download='$fl'>'$fl'";
echo "</a>";
echo "</span>";
$size = filesize($fl);
$size = getsize($size, 'mb');
echo "</td>";
echo "<td width=400px>";
echo "容量:";
echo "<span style='font-size:6px;'>$size.'M'";
echo "</span>";
echo "</td>";
echo "<td width=400px>";
echo "修改时间:";
echo "<span style='font-size:6px;'>" .date("Y-m-d H:i:s",$cfiletime);
echo "</span>";
echo "<br>";
echo "</td>";
echo "</table>";
}
}
}
}
}
read_all('.');
echo "<br/>";
echo "<a href='400W常用密码/index.php'>";
echo "<button>400W常用密码</button>";
echo "</a>";
echo " ";
echo "<a href='WPA英文字典/index.php'>";
echo "<button>WPA英文字典</button>";
echo "</a>";
echo " ";
echo "<a href='弱口令集/index.php'>";
echo "<button>弱口令集</button>";
echo "</a>";
echo " ";
echo "<a href='生日1980-2010年/index.php'>";
echo "<button>生日1980-2010年</button>";
echo "</a>";
echo " ";
echo "<a href='超级字典/index.php'>";
echo "<button>超级字典</button>";
echo "</a>";
#echo "</body>";
?>
返回(2018-06-21)
<?php
#echo "<body style='background:url(o_cheng.jpg)'; backgroundRepeat:'no-repeat'; backgroundPosition='top center'; >";
header("Content-type: text/html; charset=utf-8");
echo "<h3 align='center'>";
echo "夏天分享小知识";
echo "</h3>";
ini_set('date.timezone','Asia/Shanghai');
function getsize($size, $format = 'kb') {
$p = 0;
if ($format == 'kb') {
$p = 1;
} elseif ($format == 'mb') {
$p = 2;
} elseif ($format == 'gb') {
$p = 3;
}
$size /= pow(1024, $p);
return number_format($size, 3);
}
function read_all ($dir){
if(!is_dir($dir)) return false; $handle = opendir($dir); if($handle){
while(($fl = readdir($handle)) !== false){
$temp = iconv('utf-8','utf-8',$dir.DIRECTORY_SEPARATOR.$fl);
if(is_dir($temp) && $fl!='.' && $fl != '..'){
#echo '目录:'.$temp.'<br>';
#read_all($temp);
}else{
if($fl!='.' && $fl != '..'){
#echo $fl;
#echo '文件:'.$temp.'<br>';
$cfiletime = filectime($fl);
$mfiletime = filemtime($fl);
echo "<table>";
echo "<td width=400px>";
echo "文件:";
echo "<span style='font-size:6px;'>";
echo "<a href='$fl' download='$fl'>'$fl'";
echo "</a>";
echo "</span>";
$size = filesize($fl);
$size = getsize($size, 'mb');
echo "</td>";
echo "<td width=400px>";
echo "容量:";
echo "<span style='font-size:6px;'>$size.'M'";
echo "</span>";
echo "</td>";
echo "<td width=400px>";
echo "修改时间:";
echo "<span style='font-size:6px;'>".date("Y-m-d H:i:s",$cfiletime);
echo "</span>";
#echo "创建时间:".date("Y-m-d H:i:s",$cfiletime);
#echo "修改时间:".date("Y-m-d H:i:s",$mfiletime);
echo "<br>";
echo "</td>";
echo "</table>";
}
}
}
}
}
read_all('.');
echo "<br/>";
echo "<a href='../index.php'>";
echo "<button>返回</button>";
echo "</a>";
#echo "</body>";
?>
作用:点击链接实现下载文件

PHP获取Linux当前目录下文件并实现下载功能的更多相关文章
- python 获取当前目录下文件(转)
今天继续整理原来写的 python 代码,下面是获取文件信息的 python 处理代码. 获取指定目录下文件的文件名以及文件的数量,然后列出其中还存在的目录名称: #!/usr/bin/env pyt ...
- Java获取Linux上指定文件夹下所有第一级子文件夹
说明:需要只获得第一级文件夹目录 package com.sunsheen.jfids.studio.monitor.utils; import java.io.BufferedReader; imp ...
- linux 目录下文件批量植入和删除,按日期打包
linux目录下文件批量植入 [root@greymouster http2]# find /usr/local/http2/htdocs/ -type f|xargs sed -i " ...
- IO流-获取指定目录下文件夹和文件对象【File类】
一.运用File类实现获取指定目录下文件夹和文件对象 1.File类 2.方法: 获取文件绝对路径 :getAbsolutePath 案例: import java.io.File; /** * 获取 ...
- 【Linux】文件拷贝-Linux当前目录所有文件移动到上一级目录(转)
Linux当前目录所有文件移动到上一级目录 mv * ../
- Linux系统下文件压缩与打包命令
Linux系统下文件压缩与打包命令 常用的压缩文件拓展名 * .Z * .zip * .gz * .bz2 * .xz * .tar * .tar.gz * .tar.bz2 * .tar.xz 压缩 ...
- Spring Boot 获取 java resources 下文件
Spring Boot 获取 java resources 下文件 Spring Boot 获取 resources 目录下的目录(例:获取 resources 目录下的 template 目录): ...
- 查看当前目录下文件个数: $find ./ | wc -l
2.1. 创建和删除 创建:mkdir 删除:rm 删除非空目录:rm -rf file目录 删除日志 rm *log (等价: $find ./ -name "*log" -ex ...
- linux CentOS 安装rz和sz命令 lrzsz 实现windows和linux之间的文件上传 下载
https://blog.nbhao.org/1902.html https://bbs.csdn.net/topics/391989523 https://www.cnblogs.com/zhoul ...
随机推荐
- 回车和刷新以及Ctr+F5的区别
回车(url跳转)主要是判断本地缓存文件的Expires的有效时间,如果有效则直接使用客户端缓存 不在提交到HTTP服务器 F5 Expires设置不再起效果,只有Last-Modified/ETag ...
- ZOJ 3690 Choosing number(矩阵)
Choosing number [题目链接]Choosing number [题目类型]矩阵 &题解: 这题就和已经dp极像了,所以找方程就很困难了.可以这样找: 设f(n)是前n-1个人已经 ...
- centos7上安装nodejs
1. 确保安装编译工具 $ yum -y install gcc gcc-c++ 2. 获取官网源码 : $ wget https://nodejs.org/dist/v9.9.0/node-v9.9 ...
- 008-副文本编辑器UEditor
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- steam Depot 生成与应用脚本
Depot 生成脚本 首先为您上传的每个 Depot 创建一个 Depot 生成脚本.从复制 depot_build_1001.vdf 脚本开始,并按将上传的 Depot ID 命名. Depot 生 ...
- Yii ActiveRecord生命周期
- html5闰年判断函数
<script> var year=2016; function runnian(year){ if (year%400==0) {return ...
- html5-内联框架
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- Vector集合——单列集合的“祖宗”类
是实现可增长的对象数组:所以底层也是数组: 与collection集合不同的是,vector是同步的,意味着是单线程的,意味着效率低,速度慢, 所以在jdk1.2版本之后被ArrayList集合所取代 ...
- CentOS7使用yum命令安装Java1.8
CentOS7使用yum命令安装Java1.8 首先更新已安装的包:#yum update查看系统当前的java版本:#java -version==================== CentOS ...