国内流行的内容管理系统(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.

136 lines
4.3KB

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