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

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