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

134 lines
5.2KB

  1. <?php
  2. /**
  3. * 文件管理器查看
  4. *
  5. * @version $id:file_manage_view.php 8:48 2010年7月13日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('plus_文件管理器');
  13. require_once(DEDEINC."/libraries/oxwindow.class.php");
  14. $activepath = str_replace("..", "", $activepath);
  15. $activepath = preg_replace("#^\/{1,}#", "/", $activepath);
  16. if ($activepath == "/") $activepath = '';
  17. if ($activepath == "") $inpath = $cfg_basedir;
  18. else $inpath = $cfg_basedir.$activepath;
  19. //修改文件名
  20. if ($fmdo == "rename") {
  21. if ($activepath == "") $ndirstring = "根目录";
  22. $ndirstring = $activepath;
  23. $wintitle = "修改指定文件名称";
  24. $win = new OxWindow();
  25. $win->Init("file_manage_control.php", "/static/web/js/admin.blank.js", "POST");
  26. $win->AddHidden("fmdo", $fmdo);
  27. $win->AddHidden("activepath", $activepath);
  28. $win->AddHidden("filename", $filename);
  29. $win->AddTitle("修改文件名,当前路径:$ndirstring");
  30. $win->AddItem("旧名称:", "<input type='input' name='oldfilename' id='oldfilename' class='admin-input-md' value='$filename'>");
  31. $win->AddItem("新名称:", "<input type='input' name='newfilename' id='newfilename' class='admin-input-md'>");
  32. $winform = $win->GetWindow("ok");
  33. $win->Display();
  34. }
  35. //新建目录
  36. else if ($fmdo == "newdir") {
  37. if ($activepath == "") $activepathname = "根目录";
  38. else $activepathname = $activepath;
  39. $wintitle = "新建文件目录";
  40. $win = new OxWindow();
  41. $win->Init("file_manage_control.php", "/static/web/js/admin.blank.js", "POST");
  42. $win->AddHidden("fmdo", $fmdo);
  43. $win->AddHidden("activepath", $activepath);
  44. $win->AddHidden("token", make_hash());
  45. $win->AddTitle("当前目录 $activepathname ");
  46. $win->AddItem("新目录:", "<input type='input' name='newpath' id='newpath' class='admin-input-md'>");
  47. $winform = $win->GetWindow("ok");
  48. $win->Display();
  49. }
  50. //移动文件
  51. else if ($fmdo == "move") {
  52. $wintitle = "移动指定文件";
  53. $win = new OxWindow();
  54. $win->Init("file_manage_control.php", "/static/web/js/admin.blank.js", "POST");
  55. $win->AddHidden("fmdo", $fmdo);
  56. $win->AddHidden("activepath", $activepath);
  57. $win->AddHidden("filename", $filename);
  58. $win->AddTitle("新位置前面不加斜杆/表示相对于当前位置,加斜杆/表示相对于根目录");
  59. $win->AddItem("被移动文件:", $filename);
  60. $win->AddItem("当前位置:", $activepath);
  61. $win->AddItem("新位置:", "<input type='input' name='newpath' id='newpath' class='admin-input-md'>");
  62. $winform = $win->GetWindow("ok");
  63. $win->Display();
  64. }
  65. //删除文件
  66. else if ($fmdo == "del") {
  67. $wintitle = "删除指定文件";
  68. $win = new OxWindow();
  69. $win->Init("file_manage_control.php", "/static/web/js/admin.blank.js", "POST");
  70. $win->AddHidden("fmdo", $fmdo);
  71. $win->AddHidden("activepath", $activepath);
  72. $win->AddHidden("filename", $filename);
  73. if (@is_dir($cfg_basedir.$activepath."/$filename")) {
  74. $msg = "<tr><td>您确定要删除".$filename."目录吗</td></tr>";
  75. } else {
  76. $msg = "<tr><td>您确定要删除".$filename."文件吗</td></tr>";
  77. }
  78. $win->AddTitle("删除文件确认");
  79. $win->AddMsgItem($msg);
  80. $winform = $win->GetWindow("ok");
  81. $win->Display();
  82. }
  83. //修改文件
  84. else if ($fmdo == "edit") {
  85. if (DEDEBIZ_SAFE_MODE) {
  86. die(DedeAlert("系统已启用安全模式,无法使用当前功能",ALERT_DANGER));
  87. }
  88. if (!isset($backurl)) {
  89. $backurl = '';
  90. }
  91. $activepath = str_replace("..", "", $activepath);
  92. $filename = str_replace("..", "", $filename);
  93. $file = "$cfg_basedir$activepath/$filename";
  94. $content = '';
  95. if (is_file($file)) {
  96. $fp = fopen($file, "r");
  97. $content = fread($fp, filesize($file));
  98. fclose($fp);
  99. $content = dede_htmlspecialchars($content);
  100. }
  101. $contentView = "<textarea name='str' id='str' class='admin-textarea-xl'>$content</textarea>\r\n";
  102. $GLOBALS['filename'] = $filename;
  103. $path_parts = pathinfo($filename);
  104. if ($path_parts['extension'] == 'php') {
  105. $GLOBALS['extension'] = 'text/x-php';
  106. } else if ($path_parts['extension'] == 'js') {
  107. $GLOBALS['extension'] = 'text/javascript';
  108. } else if ($path_parts['extension'] == 'css') {
  109. $GLOBALS['extension'] = 'text/css';
  110. } else {
  111. $GLOBALS['extension'] = 'text/html';
  112. }
  113. $ctp = new DedeTagParse();
  114. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  115. $ctp->display();
  116. }
  117. //新建文件
  118. else if ($fmdo == "newfile") {
  119. $content = '';
  120. $GLOBALS['filename'] = "newfile.txt";
  121. $GLOBALS['extension'] = 'text/html';
  122. $contentView = "<textarea id='str' name='str' class='admin-textarea-xl'></textarea>\r\n";
  123. $GLOBALS['token'] = make_hash();
  124. $ctp = new DedeTagParse();
  125. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  126. $ctp->display();
  127. }
  128. //上传文件
  129. else if ($fmdo == "upload") {
  130. $ctp = new DedeTagParse();
  131. $ctp->LoadTemplate(DEDEADMIN."/templets/file_upload.htm");
  132. $ctp->display();
  133. }
  134. ?>