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

135 lines
5.5KB

  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 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. $wecome_info = "<a href='file_manage_main.php?activepath=$activepath'>文件管理</a> - 修改文件名称";
  25. $win = new OxWindow();
  26. $win->Init("file_manage_control.php", "js/blank.js", "POST");
  27. $win->AddHidden("fmdo", $fmdo);
  28. $win->AddHidden("activepath", $activepath);
  29. $win->AddHidden("filename", $filename);
  30. $win->AddTitle("修改文件名,当前路径:$ndirstring");
  31. $win->AddItem("旧名称:", "<input type='input' name='oldfilename' id='oldfilename' class='admin-input-md' value='$filename'>");
  32. $win->AddItem("新名称:", "<input type='input' name='newfilename' id='newfilename' class='admin-input-md'>");
  33. $winform = $win->GetWindow("ok");
  34. $win->Display();
  35. }
  36. //新建目录
  37. else if ($fmdo == "newdir") {
  38. if ($activepath == "") $activepathname = "根目录";
  39. else $activepathname = $activepath;
  40. $wintitle = "新建文件目录";
  41. $wecome_info = "<a href='file_manage_main.php?activepath=$activepath'>文件管理</a> - 新建目录";
  42. $win = new OxWindow();
  43. $win->Init("file_manage_control.php", "js/blank.js", "POST");
  44. $win->AddHidden("fmdo", $fmdo);
  45. $win->AddHidden("activepath", $activepath);
  46. $win->AddHidden("token", make_hash());
  47. $win->AddTitle("当前目录 $activepathname ");
  48. $win->AddItem("新目录:", "<input type='input' name='newpath' id='newpath' class='admin-input-md'>");
  49. $winform = $win->GetWindow("ok");
  50. $win->Display();
  51. }
  52. //移动文件
  53. else if ($fmdo == "move") {
  54. $wintitle = "移动指定文件";
  55. $wecome_info = "<a href='file_manage_main.php?activepath=$activepath'>文件管理</a> - 移动文件</a>";
  56. $win = new OxWindow();
  57. $win->Init("file_manage_control.php", "js/blank.js", "POST");
  58. $win->AddHidden("fmdo", $fmdo);
  59. $win->AddHidden("activepath", $activepath);
  60. $win->AddHidden("filename", $filename);
  61. $win->AddTitle("新位置前面不加'/'表示相对于当前位置,加'/'表示相对于根目录");
  62. $win->AddItem("被移动文件:", $filename);
  63. $win->AddItem("当前位置:", $activepath);
  64. $win->AddItem("新位置:", "<input type='input' name='newpath' id='newpath' class='admin-input-md'>");
  65. $winform = $win->GetWindow("ok");
  66. $win->Display();
  67. }
  68. //删除文件
  69. else if ($fmdo == "del") {
  70. $wintitle = "删除指定文件";
  71. $wecome_info = "<a href='file_manage_main.php?activepath=$activepath'>文件管理</a> - 删除文件";
  72. $win = new OxWindow();
  73. $win->Init("file_manage_control.php", "js/blank.js", "POST");
  74. $win->AddHidden("fmdo", $fmdo);
  75. $win->AddHidden("activepath", $activepath);
  76. $win->AddHidden("filename", $filename);
  77. if (@is_dir($cfg_basedir.$activepath."/$filename")) {
  78. $msg = "<tr><td>您确定要删除<span class='text-primary'>$filename</span>目录吗</td></tr>";
  79. } else {
  80. $msg = "<tr><td>您确定要删除<span class='text-primary'>$filename</span>文件吗</td></tr>";
  81. }
  82. $win->AddTitle("删除文件确认");
  83. $win->AddMsgItem($msg);
  84. $winform = $win->GetWindow("ok");
  85. $win->Display();
  86. }
  87. //修改文件
  88. else if ($fmdo == "edit") {
  89. if (!isset($backurl)) {
  90. $backurl = "";
  91. }
  92. $activepath = str_replace("..", "", $activepath);
  93. $filename = str_replace("..", "", $filename);
  94. $file = "$cfg_basedir$activepath/$filename";
  95. $content = "";
  96. if (is_file($file)) {
  97. $fp = fopen($file, "r");
  98. $content = fread($fp, filesize($file));
  99. fclose($fp);
  100. $content = dede_htmlspecialchars($content);
  101. }
  102. $contentView = "<textarea name='str' id='str' class='admin-textarea-xl'>$content</textarea>\r\n";
  103. $GLOBALS['filename'] = $filename;
  104. $path_parts = pathinfo($filename);
  105. if ($path_parts['extension'] == 'php') {
  106. $GLOBALS['extension'] = 'text/x-php';
  107. } else if ($path_parts['extension'] == 'js') {
  108. $GLOBALS['extension'] = 'text/javascript';
  109. } else if ($path_parts['extension'] == 'css') {
  110. $GLOBALS['extension'] = 'text/css';
  111. } else {
  112. $GLOBALS['extension'] = 'text/html';
  113. }
  114. $ctp = new DedeTagParse();
  115. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  116. $ctp->display();
  117. }
  118. //新建文件
  119. else if ($fmdo == "newfile") {
  120. $content = "";
  121. $GLOBALS['filename'] = "newfile.txt";
  122. $GLOBALS['extension'] = 'text/html';
  123. $contentView = "<textarea id='str' name='str' class='admin-textarea-xl'></textarea>\r\n";
  124. $GLOBALS['token'] = make_hash();
  125. $ctp = new DedeTagParse();
  126. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  127. $ctp->display();
  128. }
  129. //上传文件
  130. else if ($fmdo == "upload") {
  131. $ctp = new DedeTagParse();
  132. $ctp->LoadTemplate(DEDEADMIN."/templets/file_upload.htm");
  133. $ctp->display();
  134. }
  135. ?>