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

file_manage_view.php 6.3KB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * 文件查看
  4. *
  5. * @version $Id: file_manage_view.php 1 8:48 2010年7月13日Z 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 = "&nbsp;文件管理";
  25. $wecome_info = "文件管理::修改文件名 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</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 = "&nbsp;文件管理";
  42. $wecome_info = "&nbsp;文件管理::新建目录 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</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' class='alltxt' id='newpath'>");
  50. $winform = $win->GetWindow("ok");
  51. $win->Display();
  52. }
  53. //移动文件
  54. else if ($fmdo == "move") {
  55. $wintitle = "&nbsp;文件管理";
  56. $wecome_info = "&nbsp;文件管理::移动文件 [<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' class='alltxt' id='newpath' size='40'>");
  66. $winform = $win->GetWindow("ok");
  67. $win->Display();
  68. }
  69. //删除文件
  70. else if ($fmdo == "del") {
  71. $wintitle = "&nbsp;文件管理";
  72. $wecome_info = "&nbsp;文件管理::删除文件 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</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' style='width:98%;height:450px;background:#ffffff;'>$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=="editview")
  121. {
  122. if(!isset($backurl))
  123. {
  124. $backurl = "";
  125. }
  126. if(!isset($ishead))
  127. {
  128. $ishead = "";
  129. }
  130. $activepath = str_replace("..","",$activepath);
  131. $filename = str_replace("..","",$filename);
  132. $file = "$cfg_basedir$activepath/$filename";
  133. $fp = fopen($file,"r");
  134. @$content = fread($fp,filesize($file));
  135. fclose($fp);
  136. if((eregi("<html",$content) && eregi("<body",$content)) || $ishead == "yes")
  137. {
  138. $contentView = GetEditor("str",$content,"500","Default","string","true");
  139. } else {
  140. $contentView = GetEditor("str",$content,"500","Default","string","false");
  141. }
  142. $GLOBALS['filename'] = $filename;
  143. $ctp = new DedeTagParse();
  144. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit_view.htm");
  145. $ctp->display();
  146. }
  147. */
  148. //新建文件
  149. else if ($fmdo == "newfile") {
  150. $content = "";
  151. $GLOBALS['filename'] = "newfile.txt";
  152. $GLOBALS['extension'] = 'text/html';
  153. $contentView = "<textarea id='str' name='str' style='width:98%;height:400'></textarea>\r\n";
  154. $GLOBALS['token'] = make_hash();
  155. $ctp = new DedeTagParse();
  156. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  157. $ctp->display();
  158. }
  159. //上传文件
  160. else if ($fmdo == "upload") {
  161. $ctp = new DedeTagParse();
  162. $ctp->LoadTemplate(DEDEADMIN."/templets/file_upload.htm");
  163. $ctp->display();
  164. }