当前位置: 首页 > wzjs >正文

做网站用那个浏览器免费的推文制作网站

做网站用那个浏览器,免费的推文制作网站,企业做电商网站,网站开发设计是前端吗内部环境的服务资源下载页面有访问需求&#xff0c;给开发和产品人员编写一个简洁的下载页面提供资源下载。直接用nginxphp的形式去编写了&#xff0c;这里提供展示index.php文件代码如下&#xff1a; <?php // 配置常量 define(BASE_DIR, __DIR__); // 当前脚本所在目录作…

内部环境的服务资源下载页面有访问需求,给开发和产品人员编写一个简洁的下载页面提供资源下载。直接用nginx+php的形式去编写了,这里提供展示index.php文件代码如下:

<?php
// 配置常量
define('BASE_DIR', __DIR__); // 当前脚本所在目录作为根目录
define('ALLOWED_DIR', realpath(BASE_DIR)); // 安全校验路径// 处理文件下载
if (isset($_GET['download'])) {$filePath = realpath($_GET['download']);if ($filePath && strpos($filePath, ALLOWED_DIR) === 0 && is_file($filePath)) {header('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename="' . basename($filePath) . '"');header('Content-Length: ' . filesize($filePath));readfile($filePath);exit;} else {die('<div class="p-4 text-red-500">文件不存在或禁止访问</div>');}
}// 获取当前安全目录路径
$currentDir = isset($_GET['dir']) ? realpath($_GET['dir']) : ALLOWED_DIR;
if (!$currentDir || strpos($currentDir, ALLOWED_DIR) !== 0) {$currentDir = ALLOWED_DIR; // 非法路径重置为根目录
}// 获取文件列表
$files = scandir($currentDir);
$fileList = [];
foreach ($files as $file) {if ($file == '.' || $file == '..') continue;$fullPath = $currentDir . DIRECTORY_SEPARATOR . $file;$fileList[] = ['name' => $file,'type' => is_dir($fullPath) ? 'directory' : 'file','size' => is_file($fullPath) ? formatSize(filesize($fullPath)) : '-','mtime' => date('Y-m-d H:i:s', filemtime($fullPath)),'path' => $fullPath];
}// 辅助函数:格式化文件大小
function formatSize($bytes) {$units = ['B', 'KB', 'MB', 'GB'];$index = 0;while ($bytes >= 1024 && $index < 3) {$bytes /= 1024;$index++;}return round($bytes, 2) . ' ' . $units[$index];
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>文件管理系统</title><script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-8 bg-gray-50"><div class="max-w-4xl mx-auto bg-white rounded-lg shadow-md p-6"><h1 class="text-2xl font-bold text-gray-800 mb-6">文件列表: <?= htmlspecialchars(str_replace(ALLOWED_DIR, '/', $currentDir)) ?></h1><!-- 面包屑导航(仅在非根目录显示) --><nav class="mb-4 text-sm text-gray-600"><?php$parentDir = dirname($currentDir);if ($currentDir !== ALLOWED_DIR && $parentDir != $currentDir && strpos(realpath($parentDir), ALLOWED_DIR) === 0):?><a href="?dir=<?= urlencode($parentDir) ?>" class="text-blue-500 hover:text-blue-700">⬆ 上一级</a><?php endif; ?></nav><!-- 文件表格 --><table class="w-full border-collapse"><thead class="bg-gray-50"><tr><th class="p-3 text-left text-gray-500">名称</th><th class="p-3 text-left text-gray-500">类型</th><th class="p-3 text-left text-gray-500">大小</th><th class="p-3 text-left text-gray-500">修改时间</th><th class="p-3 text-left text-gray-500">操作</th></tr></thead><tbody><?php foreach ($fileList as $item): ?><tr class="hover:bg-gray-50 border-t"><td class="p-3"><?php if ($item['type'] == 'directory'): ?><a href="?dir=<?= urlencode($item['path']) ?>" class="text-blue-500 hover:text-blue-700 flex items-center">📁 <?= htmlspecialchars($item['name']) ?></a><?php else: ?><span class="flex items-center">📄 <?= htmlspecialchars($item['name']) ?></span><?php endif; ?></td><td class="p-3 text-gray-600"><?= $item['type'] == 'directory' ? '文件夹' : '文件' ?></td><td class="p-3 text-gray-600"><?= $item['size'] ?></td><td class="p-3 text-gray-600"><?= $item['mtime'] ?></td><td class="p-3"><?php if ($item['type'] == 'file'): ?><a href="?download=<?= urlencode($item['path']) ?>" class="px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">下载</a><?php else: ?><span class="text-gray-400">-</span><?php endif; ?></td></tr><?php endforeach; ?></tbody></table></div>
</body>
</html>

最终的页面展示:

http://www.dtcms.com/wzjs/82495.html

相关文章:

  • 网站如何做链接四川旅游seo整站优化
  • 清远专业网站建设服务石家庄seo管理
  • 开拓网站建设上海短视频推广
  • 福州专业网站设计团队百度app首页
  • 成都市做网站的公司济南网站推广优化
  • 地方性网站赚钱google ads 推广
  • 企业如何免费做网站bt磁力猫
  • 东莞微信网站建设推荐制作一个app软件需要多少钱
  • 做外贸有必要做个网站吗推广策略有哪些方法
  • linux 下启动 wordpressseo还有用吗
  • 国际新闻最近新闻军事seo职位描述
  • 如何做网站外链站长统计软件
  • 打开百度网站建设一周热点新闻
  • 带购物车的网站模板数字营销课程
  • 网站怎么提高百度权重本地服务推广平台哪个好
  • 制作网站品牌公司哪家好北京seo优化哪家好
  • 网站建设蓝色工匠百度一下官网首页登录
  • 宁波专业网站制作服务长沙关键词优化服务
  • 免费香港网站空间搜索引擎优化工具
  • 无锡网站建设 网站制作网页搜索引擎优化技术
  • 培训seo技术seo博客教程
  • 导购网站怎么做seo专业培训费用
  • 张家港哪家做企业网站友情链接交换系统
  • 给私人企业做网站推广搜狗推广登录
  • 柬埔寨美女教你用母乳做奶茶原网站免费p站推广网站入口
  • 怀远做网站百度店铺怎么入驻
  • 韩式摄影网站源码免费模板网站
  • 佛山网站建设熊掌号seo优化网站优化排名
  • 织梦网站图片不显示图片邯郸seo推广
  • 怎么做那些盗号网站最新资讯热点