找回密码
 注册
搜索
免费空间 免费域名 免费AI 老牌主机商首月仅1美分!27美元/年!Namecheap优惠码Spaceship优惠码
查看: 574|回复: 14

[程序代码] chez.com空间双栏文件管理系统开源源码分享

[复制链接]
发表于 2025-12-27 23:48:43 | 显示全部楼层 |阅读模式


经过两天的测试,从V1.0版改进到了V9.7版。

新增了密码登陆功能,更安全!

完整的双栏文件列表(左/右两侧)。

多文件上传功能。

文件全选功能

批量移动(移至对侧)功能。

新建文件/文件夹功能。

属性权限修改功能(在chez.com无效,beget空间测试有效。)

重命名功能

单文件下载功能

文件编辑功能。

批量删除等。

目前只在chez.com空间测试,其他空间没有测试。

双栏式文件管理移动文件便捷!
属性只有查看功能,并不具备修改功能。
文件编辑功能可以编辑图片,编辑之后图片失效,慎用!

复制以下源码保存为batch_move.php或自定义前缀名,属性设置为644

默认密码:123456,请修改后再上传。
  1. <?php
  2. /**
  3. * TMD Master v9.7 - 兼容性安全增强版
  4. * 修复:解决 Chez.com 报错 "session_start() failed"
  5. * 原理:改用 Cookie 验证,并手动屏蔽陈旧环境的报错。
  6. */
  7. error_reporting(0);
  8. @ini_set('display_errors', 0);

  9. // ================= 配置区 =================
  10. $password = "123456"; // 请修改你的登录密码
  11. // ==========================================

  12. $script_name = basename(__FILE__);
  13. $auth_key = md5($password . 'tmd_salt');

  14. // 退出逻辑
  15. if (isset($_GET['logout'])) {
  16.     setcookie("tmd_token", "", time() - 3600);
  17.     header("Location: " . $script_name);
  18.     exit;
  19. }

  20. // 登录验证逻辑
  21. if (isset($_POST['login_pass'])) {
  22.     if ($_POST['login_pass'] === $password) {
  23.         setcookie("tmd_token", $auth_key, time() + 86400 * 7); // 有效期7天
  24.         header("Location: " . $script_name);
  25.         exit;
  26.     }
  27. }

  28. // 检查 Cookie 是否匹配
  29. $is_logged = (isset($_COOKIE['tmd_token']) && $_COOKIE['tmd_token'] === $auth_key);

  30. if (!$is_logged) {
  31.     die('<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Login</title>
  32.     <style>
  33.         body { background: #f4f4f4; display: flex; justify-content: center; align-items: center; height: 100vh; font-family: sans-serif; }
  34.         .login-box { background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; }
  35.         input { padding: 10px; border: 1px solid #ddd; border-radius: 4px; width: 200px; margin-bottom: 15px; display: block; font-size: 16px; }
  36.         button { background: #333; color: #fff; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; width: 100%; font-weight: bold; }
  37.     </style></head><body>
  38.     <div class="login-box">
  39.         <h3>🔒 身份验证</h3>
  40.         <form method="post">
  41.             <input type="password" name="login_pass" placeholder="输入密码" autofocus>
  42.             <button type="submit">进入管理系统</button>
  43.         </form>
  44.         <p style="font-size:11px; color:#999; margin-top:15px;">Chez.com 兼容模式已激活</p>
  45.     </div></body></html>');
  46. }

  47. // --- 以下为文件管理逻辑 ---
  48. header("Content-Type: text/html; charset=utf-8");
  49. $root_path = realpath("./");

  50. function format_size_info($s) {
  51.     if ($s >= 1048576) { return round($s / 1048576, 2) . " MB"; }
  52.     if ($s >= 1024) { return round($s / 1024, 1) . " KB"; }
  53.     return $s . " B";
  54. }

  55. function recursive_delete($t) {
  56.     if (is_dir($t)) {
  57.         $items = @scandir($t);
  58.         if ($items) {
  59.             foreach ($items as $item) {
  60.                 if ($item != "." && $item != "..") { recursive_delete($t . DIRECTORY_SEPARATOR . $item); }
  61.             }
  62.         }
  63.         return @rmdir($t);
  64.     }
  65.     return @unlink($t);
  66. }

  67. $p_l = isset($_GET["pL"]) ? $_GET["pL"] : "";
  68. $p_r = isset($_GET["pR"]) ? $_GET["pR"] : "";
  69. $d_l = realpath($root_path . "/" . $p_l) . DIRECTORY_SEPARATOR;
  70. $d_r = realpath($root_path . "/" . $p_r) . DIRECTORY_SEPARATOR;

  71. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  72.     $side = isset($_POST["side"]) ? $_POST["side"] : "";
  73.     $base = ($side == "L") ? $d_l : $d_r;
  74.     $jump = false;
  75.    
  76.     if (isset($_POST["sv"])) { file_put_contents(realpath($root_path . "/" . $_POST["ep"]), $_POST["ct"]); $jump = true; }
  77.     if (isset($_POST["ch"])) {
  78.         $target = realpath($root_path . "/" . $_POST["op"]);
  79.         if ($target) { @chmod($target, octdec($_POST["nv"])); $jump = true; }
  80.     }
  81.     if (isset($_POST["rn"])) {
  82.         $old_f = realpath($root_path . "/" . $_POST["op"]);
  83.         if ($old_f && basename($old_f) !== $script_name) { @rename($old_f, dirname($old_f) . DIRECTORY_SEPARATOR . $_POST["nn"]); $jump = true; }
  84.     }
  85.     if (isset($_POST["nf"])) { @mkdir($base . $_POST["folder_name"], 0755); $jump = true; }
  86.     if (isset($_POST["ni"])) { file_put_contents($base . $_POST["file_name"], ""); $jump = true; }
  87.     if (isset($_POST["bd"]) && isset($_POST["its"])) {
  88.         foreach ($_POST["its"] as $i) { if ($i !== $script_name) recursive_delete($base . $i); }
  89.         $jump = true;
  90.     }
  91.     if (isset($_POST["mv_to_opp"]) && isset($_POST["its"])) {
  92.         $target_dir = ($side == "L") ? $d_r : $d_l;
  93.         foreach ($_POST["its"] as $i) { if ($i !== $script_name) @rename($base . $i, $target_dir . $i); }
  94.         $jump = true;
  95.     }
  96.     if (isset($_POST["up"]) && isset($_FILES["fs"])) {
  97.         foreach ($_FILES["fs"]["tmp_name"] as $k => $tmp) { if ($tmp) @move_uploaded_file($tmp, $base . $_FILES["fs"]["name"][$k]); }
  98.         $jump = true;
  99.     }
  100.     if ($jump) { header("Location: ?pL=" . urlencode($p_l) . "&pR=" . urlencode($p_r)); exit; }
  101. }

  102. $f_l = array_diff(@scandir($d_l) ? @scandir($d_l) : array(), array(".", ".."));
  103. $f_r = array_diff(@scandir($d_r) ? @scandir($d_r) : array(), array(".", ".."));
  104. ?>
  105. <!DOCTYPE html>
  106. <html>
  107. <head>
  108.     <meta charset="UTF-8">
  109.     <title>TMD Master v9.7</title>
  110.     <style>
  111.         body { font-size: 13px; font-family: sans-serif; background: #eee; margin: 10px; }
  112.         .box { background: #fff; border: 1px solid #ccc; min-width: 950px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
  113.         .header { padding: 12px; background: #333; color: #fff; font-weight: bold; display: flex; justify-content: space-between; align-items: center;}
  114.         .dual { display: flex; height: 600px; border-top: 1px solid #ccc; }
  115.         .pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #fff; }
  116.         .list { flex: 1; overflow-y: auto; }
  117.         .item { display: flex; padding: 7px 10px; border-bottom: 1px solid #eee; align-items: center; }
  118.         .item:hover { background: #f9f9f9; }
  119.         .item-info { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; }
  120.         .btns { display: none; gap: 4px; }
  121.         .item:hover .btns { display: flex; }
  122.         .head-info { background: #f1f1f1; padding: 10px; border-bottom: 1px solid #ddd; font-size: 11px; display: flex; align-items: center; justify-content: space-between; }
  123.         .tool { padding: 10px; background: #f4f4f4; border-top: 1px solid #ddd; }
  124.         button, .btn-link { cursor: pointer; padding: 3px 8px; border: 1px solid #bbb; font-size: 11px; background: #fff; font-weight: bold; text-decoration: none; color: #333; }
  125.         .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1000; }
  126.         .m-con { background: #fff; width: 420px; margin: 100px auto; padding: 20px; border-radius: 4px; }
  127.         textarea { width: 100%; height: 450px; font-family: monospace; }
  128.         .logout { color: #ff9a9a; border: 1px solid #ff9a9a; padding: 2px 8px; border-radius: 3px; font-size: 11px; text-decoration: none; }
  129.     </style>
  130. </head>
  131. <body>
  132. <div class="box">
  133.     <div class="header">
  134.         <span>📂 TMD Master v9.7 | Cookie 兼容版</span>
  135.         <a href="?logout=1" class="logout">安全退出</a>
  136.     </div>
  137.     <div class="dual">
  138.         <?php
  139.         $sides = array("L", "R");
  140.         foreach($sides as $s) {
  141.             $cp = ($s == "L") ? $p_l : $p_r; $op = ($s == "L") ? $p_r : $p_l;
  142.             $fl = ($s == "L") ? $f_l : $f_r; $bd = ($s == "L") ? $d_l : $d_r;
  143.             echo '<div class="pane">';
  144.             echo '<div class="head-info"><div>📍 /' . htmlspecialchars($cp) . '</div>';
  145.             echo '<a href="' . ($s == "L" ? "?pL=&pR=".urlencode($op) : "?pL=".urlencode($op)."&pR=") . '" style="color:#d35400; font-weight:bold;">🏠 根目录</a></div>';
  146.             echo '<form method="post" id="f_'.$s.'" class="list"><input type="hidden" name="side" value="'.$s.'">';
  147.             echo '<div class="item" style="background:#fafafa;"><input type="checkbox" onclick="var c=document.getElementsByClassName(\'s-'.$s.'\');for(var i=0;i<c.length;i++)c[i].checked=this.checked;"> <b style="margin-left:5px;">全选</b>';
  148.             if($cp != "") {
  149.                 $upd = dirname($cp); if ($upd == "." || $upd == "") $upd = "";
  150.                 echo '<a href="' . ($s == "L" ? "?pL=".urlencode($upd)."&pR=".urlencode($op) : "?pL=".urlencode($op)."&pR=".urlencode($upd)) . '" style="margin-left:auto; text-decoration:none; font-weight:bold;">⬅️ 上级</a>';
  151.             }
  152.             echo '</div>';
  153.             foreach($fl as $fn) {
  154.                 $full = $bd . $fn; $is_d = @is_dir($full); $rel = ($cp != "" ? $cp . "/" : "") . $fn;
  155.                 $pv = @fileperms($full); $np = ($pv !== false) ? substr(sprintf("%o", $pv), -4) : "0000";
  156.                 $is_me = ($fn === $script_name);
  157.                 echo '<div class="item"><input type="checkbox" name="its[]" value="'.htmlspecialchars($fn).'" class="s-'.$s.'" '.($is_me?"disabled":"").'>';
  158.                 echo '<div class="item-info">' . ($is_d ? '📁 <a href="'.($s=="L"?"?pL=".urlencode($rel."/")."&pR=".urlencode($op):"?pL=".urlencode($op)."&pR=".urlencode($rel."/")).'" style="color:#d35400; font-weight:bold; text-decoration:none;">'.htmlspecialchars($fn).'</a>' : '📄 <a href="'.htmlspecialchars($rel).'" target="_blank" style="color:#2c3e50; text-decoration:none;">'.htmlspecialchars($fn).'</a>') . '</div>';
  159.                 echo '<div class="btns"><a onclick="openChmod(\''.$rel.'\',\''.$np.'\')" class="btn-link" style="color:#e67e22;">'.$np.'</a>';
  160.                 if(!$is_d) { echo '<a onclick="ed(\''.$rel.'\')" class="btn-link" style="color:#27ae60;">编辑</a><a href="?dl='.urlencode($rel).'" class="btn-link" style="color:#2980b9;">下载</a>'; }
  161.                 if(!$is_me) { echo '<a onclick="var n=prompt(\'新名\',\''.$fn.'\');if(n){rn(\''.$rel.'\',n)}" class="btn-link">名</a><a onclick="if(confirm(\'删?\')){del(\''.$s.'\',\''.htmlspecialchars($fn).'\')}" class="btn-link" style="color:red;">删</a>'; }
  162.                 echo '</div><span style="color:#999; font-size:10px; width:60px; text-align:right;">'.($is_d?"--":format_size_info(@filesize($full))).'</span></div>';
  163.             }
  164.             echo '</form><div class="tool"><div style="display:flex; gap:4px; margin-bottom:5px;"><button type="submit" form="f_'.$s.'" name="mv_to_opp" style="flex:1; background:#2c3e50; color:#fff; border:none; padding:6px;">👉 批量移动</button><button type="submit" form="f_'.$s.'" name="bd" style="background:red; color:#fff; border:none; padding:6px;" onclick="return confirm(\'删?\')">🗑 批量删</button></div>';
  165.             echo '<div style="display:flex; gap:3px;"><button onclick="newF(\''.$s.'\',\'nf\')">新目录</button><button onclick="newF(\''.$s.'\',\'ni\')">新文件</button>';
  166.             echo '<form method="post" enctype="multipart/form-data" style="margin-left:auto;"><input type="hidden" name="side" value="'.$s.'"><input type="file" name="fs[]" multiple style="width:100px;"><button type="submit" name="up" style="background:#27ae60; color:#fff; border:none;">上传</button></form></div></div></div>';
  167.             if($s == "L") echo '<div style="width:2px; background:#444;"></div>';
  168.         }
  169.         ?>
  170.     </div>
  171. </div>

  172. <div id="chmodModal" class="modal"><div class="m-con">
  173.     <h4>修改属性</h4>
  174.     <table style="width:100%; text-align:center;">
  175.         <tr><th>位</th><th>读</th><th>写</th><th>执</th></tr>
  176.         <tr><td>主</td><td><input type="checkbox" class="p-bit" value="400"></td><td><input type="checkbox" class="p-bit" value="200"></td><td><input type="checkbox" class="p-bit" value="100"></td></tr>
  177.         <tr><td>组</td><td><input type="checkbox" class="p-bit" value="40"></td><td><input type="checkbox" class="p-bit" value="20"></td><td><input type="checkbox" class="p-bit" value="10"></td></tr>
  178.         <tr><td>客</td><td><input type="checkbox" class="p-bit" value="4"></td><td><input type="checkbox" class="p-bit" value="2"></td><td><input type="checkbox" class="p-bit" value="1"></td></tr>
  179.     </table>
  180.     <div style="text-align:center; font-weight:bold; font-size:18px; margin:10px; color:orange;">数值:<span id="permVal">0000</span></div>
  181.     <form method="post"><input type="hidden" name="ch" value="1"><input type="hidden" name="op" id="chmodOp"><input type="hidden" name="nv" id="chmodNv"><button type="submit" style="width:100%; background:green; color:#fff; padding:10px; border:none;">应用</button></form>
  182.     <button onclick="document.getElementById('chmodModal').style.display='none'" style="width:100%; margin-top:5px;">取消</button>
  183. </div></div>

  184. <div id="m" class="modal"><div class="m-con" style="width:90%; max-width:1000px; margin-top:30px;">
  185.     <h4 id="mn">编辑器</h4>
  186.     <form method="post"><input type="hidden" name="ep" id="ep"><textarea name="ct" id="ca" spellcheck="false"></textarea><br><br>
  187.     <button type="submit" name="sv" style="background:green; color:#fff; padding:10px; border:none;">💾 保存</button><button type="button" onclick="document.getElementById('m').style.display='none'">关闭</button>
  188. </form></div></div>

  189. <script>
  190. function ed(p){ document.getElementById('mn').innerText=p; document.getElementById('ep').value=p; document.getElementById('m').style.display='block'; var x=new XMLHttpRequest(); x.onreadystatechange=function(){if(x.readyState==4)document.getElementById('ca').value=x.responseText;}; x.open("GET","?gc="+encodeURIComponent(p),true); x.send(); }
  191. function newF(s,t){ var n=prompt('名称:'); if(n){ var f=document.createElement('form');f.method='post'; f.innerHTML='<input type="hidden" name="side" value="'+s+'"><input type="hidden" name="'+t+'" value="1"><input type="hidden" name="'+(t=='nf'?'folder_name':'file_name')+'" value="'+n+'">'; document.body.appendChild(f);f.submit(); } }
  192. function rn(o,n){ var f=document.createElement('form');f.method='post'; f.innerHTML='<input type="hidden" name="rn" value="1"><input type="hidden" name="op" value="'+o+'"><input type="hidden" name="nn" value="'+n+'">'; document.body.appendChild(f);f.submit(); }
  193. function del(s,i){ var f=document.createElement('form');f.method='post'; f.innerHTML='<input type="hidden" name="side" value="'+s+'"><input type="hidden" name="bd" value="1"><input type="hidden" name="its[]" value="'+i+'">'; document.body.appendChild(f);f.submit(); }
  194. function openChmod(o, v){ document.getElementById('chmodOp').value=o; var cur=parseInt(v,8); var bits=document.querySelectorAll('.p-bit'); for(var i=0;i<bits.length;i++){ var b=parseInt(bits[i].value,8); bits[i].checked=(cur&b)===b; bits[i].onclick=calcPerm; } calcPerm(); document.getElementById('chmodModal').style.display='block'; }
  195. function calcPerm(){ var t=0; var b=document.querySelectorAll('.p-bit'); for(var i=0;i<b.length;i++){ if(b[i].checked) t+=parseInt(b[i].value,8); } var oct="0"+t.toString(8); document.getElementById('permVal').innerText=oct; document.getElementById('chmodNv').value=oct; }
  196. </script>
  197. </body></html>
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×

评分

参与人数 1银币 +10 收起 理由
shim + 10 赞一个!

查看全部评分

发表于 2025-12-27 23:55:59 | 显示全部楼层
没有密码保护吗?
 楼主| 发表于 2025-12-27 23:57:43 | 显示全部楼层
shim 发表于 2025-12-27 23:55
没有密码保护吗?

密码功能已经更新。
发表于 2025-12-28 09:56:52 | 显示全部楼层
哈哈,一下子蹦出那么多个文件管理器了
 楼主| 发表于 2025-12-28 11:19:57 | 显示全部楼层
shim 发表于 2025-12-28 09:56
哈哈,一下子蹦出那么多个文件管理器了

我的空间里有五个文件管理器
发表于 2025-12-28 14:39:23 来自手机 | 显示全部楼层
本帖最后由 边边角角 于 2025-12-28 16:15 编辑

适用于所有的空间吗
发表于 2025-12-28 14:42:56 | 显示全部楼层
哈哈 玩的越来越花了
 楼主| 发表于 2025-12-28 15:31:59 | 显示全部楼层
xinsui 发表于 2025-12-28 14:42
哈哈 玩的越来越花了

这就是折腾的乐趣
发表于 2025-12-29 12:06:49 | 显示全部楼层
感谢分享
发表于 2026-1-14 21:10:07 | 显示全部楼层
看着不错啊,也申请了一个 chez ,ftp 不会搞
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|免费吧论坛

GMT+8, 2026-7-16 06:43 , Processed in 0.075376 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表