国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

152 Zeilen
4.6KB

  1. <?php
  2. /**
  3. * 文件管理控制
  4. *
  5. * @version $id:file_manage_control.php 8:48 2010年7月13日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 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."/libraries/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. ----------------*/
  33. else if ($fmdo == "newdir") {
  34. CheckCSRF();
  35. $fmm->NewDir($newpath);
  36. }
  37. //移动文件
  38. /*---------------
  39. function __move();
  40. ----------------*/
  41. else if ($fmdo == "move") {
  42. $fmm->MoveFile($filename, $newpath);
  43. }
  44. //删除文件
  45. /*---------------
  46. function __delfile();
  47. ----------------*/
  48. else if ($fmdo == "del") {
  49. $fmm->DeleteFile($filename);
  50. }
  51. //文件修改
  52. /*---------------
  53. function __saveEdit();
  54. ----------------*/
  55. else if ($fmdo == "edit") {
  56. CheckCSRF();
  57. $filename = str_replace("..", "", $filename);
  58. if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)$#i', trim($filename))) {
  59. ShowMsg("指定的文件名已被系统禁止", "javascript:;");
  60. exit();
  61. }
  62. $file = "$cfg_basedir$activepath/$filename";
  63. $str = stripslashes($str);
  64. $fp = fopen($file, "w");
  65. fputs($fp, $str);
  66. fclose($fp);
  67. if (empty($backurl)) {
  68. ShowMsg("成功保存一个文件", "file_manage_main.php?activepath=$activepath");
  69. } else {
  70. ShowMsg("成功保存文件", $backurl);
  71. }
  72. exit();
  73. }
  74. /*
  75. 文件修改,可视化模式
  76. function __saveEditView();
  77. else if ($fmdo=="editview")
  78. {
  79. $filename = str_replace("..","",$filename);
  80. $file = "$cfg_basedir$activepath/$filename";
  81. $str = eregi_replace('&quot;','\\"',$str);
  82. $str = stripslashes($str);
  83. $fp = fopen($file,"w");
  84. fputs($fp,$str);
  85. fclose($fp);
  86. if (empty($backurl))
  87. {
  88. $backurl = "file_manage_main.php?activepath=$activepath";
  89. }
  90. ShowMsg("成功保存文件",$backurl);
  91. exit();
  92. }
  93. */
  94. //文件上传
  95. /*---------------
  96. function __upload();
  97. ----------------*/
  98. else if ($fmdo == "upload") {
  99. $j = 0;
  100. for ($i = 1; $i <= 50; $i++) {
  101. $upfile = "upfile".$i;
  102. $upfile_name = "upfile".$i."_name";
  103. if (!isset(${$upfile}) || !isset(${$upfile_name})) {
  104. continue;
  105. }
  106. $upfile = ${$upfile};
  107. $upfile_name = ${$upfile_name};
  108. if (is_uploaded_file($upfile)) {
  109. //检查文件类型
  110. $mime = get_mime_type($upfile);
  111. if (preg_match("#^unknow#", $mime)) {
  112. ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1);
  113. exit;
  114. }
  115. if (!preg_match("#^(image|video|audio|application)#i", $mime)) {
  116. ShowMsg("仅支持媒体文件及应用程序上传", -1);
  117. exit;
  118. }
  119. if (!file_exists($cfg_basedir.$activepath."/".$upfile_name)) {
  120. move_uploaded_file($upfile, $cfg_basedir.$activepath."/".$upfile_name);
  121. }
  122. @unlink($upfile);
  123. $j++;
  124. }
  125. }
  126. ShowMsg("成功上传<span class='text-primary'>$j</span>个文件到: $activepath", "file_manage_main.php?activepath=$activepath");
  127. exit();
  128. }
  129. //空间检查
  130. else if ($fmdo == "space") {
  131. if ($activepath == "") {
  132. $ecpath = "所有目录";
  133. } else {
  134. $ecpath = $activepath;
  135. }
  136. $titleinfo = "目录[<a href='file_manage_main.php?activepath=$activepath'>$ecpath</a>]空间使用状况:<br>";
  137. $wintitle = "文件管理";
  138. $wecome_info = "<a href='file_manage_main.php?activepath=$activepath'>文件管理</a>::空间大小检查";
  139. $activepath = $cfg_basedir.$activepath;
  140. $space = new SpaceUse;
  141. $space->checksize($activepath);
  142. $total = $space->totalsize;
  143. $totalkb = $space->setkb($total);
  144. $totalmb = $space->setmb($total);
  145. $win = new OxWindow();
  146. $win->Init("", "js/blank.js", "POST");
  147. $win->AddTitle($titleinfo);
  148. $win->AddMsgItem("$totalmb M<br>$totalkb KB<br>$total 字节");
  149. $winform = $win->GetWindow("");
  150. $win->Display();
  151. }
  152. ?>