国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

file_manage_control.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /**
  3. * 文件管理控制
  4. *
  5. * @version $Id: file_manage_control.php 1 8:48 2010年7月13日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2021, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require(dirname(__FILE__) . "/config.php");
  12. CheckPurview('plus_文件管理器');
  13. require(DEDEINC . "/oxwindow.class.php");
  14. require_once(DEDEADMIN . '/file_class.php');
  15. $activepath = str_replace("..", "", $activepath);
  16. $activepath = preg_replace("#^\/{1,}#", "/", $activepath);
  17. if ($activepath == "/") $activepath = "";
  18. if ($activepath == "") $inpath = $cfg_basedir;
  19. else $inpath = $cfg_basedir . $activepath;
  20. //文件管理器交互与逻辑控制文件
  21. $fmm = new FileManagement();
  22. $fmm->Init();
  23. /*---------------
  24. function __rename();
  25. ----------------*/
  26. if ($fmdo == "rename") {
  27. $fmm->RenameFile($oldfilename, $newfilename);
  28. }
  29. //新建目录
  30. /*---------------
  31. function __newdir();
  32. ----------------*/ else if ($fmdo == "newdir") {
  33. CheckCSRF();
  34. $fmm->NewDir($newpath);
  35. }
  36. //移动文件
  37. /*---------------
  38. function __move();
  39. ----------------*/ else if ($fmdo == "move") {
  40. $fmm->MoveFile($filename, $newpath);
  41. }
  42. //删除文件
  43. /*---------------
  44. function __delfile();
  45. ----------------*/ else if ($fmdo == "del") {
  46. $fmm->DeleteFile($filename);
  47. }
  48. //文件编辑
  49. /*---------------
  50. function __saveEdit();
  51. ----------------*/ else if ($fmdo == "edit") {
  52. CheckCSRF();
  53. $filename = str_replace("..", "", $filename);
  54. $file = "$cfg_basedir$activepath/$filename";
  55. $str = stripslashes($str);
  56. $fp = fopen($file, "w");
  57. fputs($fp, $str);
  58. fclose($fp);
  59. if (empty($backurl)) {
  60. ShowMsg("成功保存一个文件!", "file_manage_main.php?activepath=$activepath");
  61. } else {
  62. ShowMsg("成功保存文件!", $backurl);
  63. }
  64. exit();
  65. }
  66. /*
  67. 文件编辑,可视化模式
  68. function __saveEditView();
  69. else if($fmdo=="editview")
  70. {
  71. $filename = str_replace("..","",$filename);
  72. $file = "$cfg_basedir$activepath/$filename";
  73. $str = eregi_replace('&quot;','\\"',$str);
  74. $str = stripslashes($str);
  75. $fp = fopen($file,"w");
  76. fputs($fp,$str);
  77. fclose($fp);
  78. if(empty($backurl))
  79. {
  80. $backurl = "file_manage_main.php?activepath=$activepath";
  81. }
  82. ShowMsg("成功保存文件!",$backurl);
  83. exit();
  84. }
  85. */
  86. //文件上传
  87. /*---------------
  88. function __upload();
  89. ----------------*/ else if ($fmdo == "upload") {
  90. $j = 0;
  91. for ($i = 1; $i <= 50; $i++) {
  92. $upfile = "upfile" . $i;
  93. $upfile_name = "upfile" . $i . "_name";
  94. if (!isset(${$upfile}) || !isset(${$upfile_name})) {
  95. continue;
  96. }
  97. $upfile = ${$upfile};
  98. $upfile_name = ${$upfile_name};
  99. if (is_uploaded_file($upfile)) {
  100. if (!file_exists($cfg_basedir . $activepath . "/" . $upfile_name)) {
  101. move_uploaded_file($upfile, $cfg_basedir . $activepath . "/" . $upfile_name);
  102. }
  103. @unlink($upfile);
  104. $j++;
  105. }
  106. }
  107. ShowMsg("成功上传 $j 个文件到: $activepath", "file_manage_main.php?activepath=$activepath");
  108. exit();
  109. }
  110. //空间检查
  111. else if ($fmdo == "space") {
  112. if ($activepath == "") {
  113. $ecpath = "所有目录";
  114. } else {
  115. $ecpath = $activepath;
  116. }
  117. $titleinfo = "目录 <a href='file_manage_main.php?activepath=$activepath'><b><u>$ecpath</u></b></a> 空间使用状况:<br/>";
  118. $wintitle = "文件管理";
  119. $wecome_info = "文件管理::空间大小检查 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</a>";
  120. $activepath = $cfg_basedir . $activepath;
  121. $space = new SpaceUse;
  122. $space->checksize($activepath);
  123. $total = $space->totalsize;
  124. $totalkb = $space->setkb($total);
  125. $totalmb = $space->setmb($total);
  126. $win = new OxWindow();
  127. $win->Init("", "js/blank.js", "POST");
  128. $win->AddTitle($titleinfo);
  129. $win->AddMsgItem("  $totalmb M<br/>  $totalkb KB<br/>  $total 字节");
  130. $winform = $win->GetWindow("");
  131. $win->Display();
  132. }