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

187 lines
6.3KB

  1. <?php
  2. /**
  3. * 文件查看
  4. *
  5. * @version $Id: file_manage_view.php 1 8:48 2010年7月13日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__)."/config.php");
  13. CheckPurview('plus_文件管理器');
  14. require_once(DEDEINC."/oxwindow.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. //更改文件名
  22. if($fmdo=="rename")
  23. {
  24. if($activepath=="") $ndirstring = "根目录";
  25. $ndirstring = $activepath;
  26. $wintitle = "&nbsp;文件管理";
  27. $wecome_info = "文件管理::更改文件名 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</a>";
  28. $win = new OxWindow();
  29. $win->Init("file_manage_control.php","js/blank.js","POST");
  30. $win->AddHidden("fmdo",$fmdo);
  31. $win->AddHidden("activepath",$activepath);
  32. $win->AddHidden("filename",$filename);
  33. $win->AddTitle("更改文件名,当前路径:$ndirstring");
  34. $win->AddItem("旧名称:","<input name='oldfilename' type='input' id='oldfilename' size='40' value='$filename'>");
  35. $win->AddItem("新名称:","<input name='newfilename' type='input' size='40' id='newfilename'>");
  36. $winform = $win->GetWindow("ok");
  37. $win->Display();
  38. }
  39. //新建目录
  40. else if($fmdo=="newdir")
  41. {
  42. if($activepath=="") $activepathname="根目录";
  43. else $activepathname=$activepath;
  44. $wintitle = "&nbsp;文件管理";
  45. $wecome_info = "&nbsp;文件管理::新建目录 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</a>";
  46. $win = new OxWindow();
  47. $win->Init("file_manage_control.php","js/blank.js","POST");
  48. $win->AddHidden("fmdo",$fmdo);
  49. $win->AddHidden("activepath",$activepath);
  50. $win->AddHidden("token",make_hash());
  51. $win->AddTitle("当前目录 $activepathname ");
  52. $win->AddItem("新目录:","<input name='newpath' type='input' class='alltxt' id='newpath'>");
  53. $winform = $win->GetWindow("ok");
  54. $win->Display();
  55. }
  56. //移动文件
  57. else if($fmdo=="move")
  58. {
  59. $wintitle = "&nbsp;文件管理";
  60. $wecome_info = "&nbsp;文件管理::移动文件 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</a>";
  61. $win = new OxWindow();
  62. $win->Init("file_manage_control.php","js/blank.js","POST");
  63. $win->AddHidden("fmdo",$fmdo);
  64. $win->AddHidden("activepath",$activepath);
  65. $win->AddHidden("filename",$filename);
  66. $win->AddTitle("新位置前面不加'/'表示相对于当前位置,加'/'表示相对于根目录。");
  67. $win->AddItem("被移动文件:",$filename);
  68. $win->AddItem("当前位置:",$activepath);
  69. $win->AddItem("新位置:","<input name='newpath' type='input' class='alltxt' id='newpath' size='40'>");
  70. $winform = $win->GetWindow("ok");
  71. $win->Display();
  72. }
  73. //删除文件
  74. else if($fmdo=="del")
  75. {
  76. $wintitle = "&nbsp;文件管理";
  77. $wecome_info = "&nbsp;文件管理::删除文件 [<a href='file_manage_main.php?activepath=$activepath'>文件浏览器</a>]</a>";
  78. $win = new OxWindow();
  79. $win->Init("file_manage_control.php","js/blank.js","POST");
  80. $win->AddHidden("fmdo",$fmdo);
  81. $win->AddHidden("activepath",$activepath);
  82. $win->AddHidden("filename",$filename);
  83. if(@is_dir($cfg_basedir.$activepath."/$filename"))
  84. {
  85. $wmsg = "你确信要删除目录:$filename 吗?";
  86. }
  87. else
  88. {
  89. $wmsg = "你确信要删除文件:$filename 吗?";
  90. }
  91. $win->AddTitle("删除文件确认");
  92. $win->AddMsgItem($wmsg,"50");
  93. $winform = $win->GetWindow("ok");
  94. $win->Display();
  95. }
  96. //编辑文件
  97. else if($fmdo=="edit")
  98. {
  99. if(!isset($backurl))
  100. {
  101. $backurl = "";
  102. }
  103. $activepath = str_replace("..","",$activepath);
  104. $filename = str_replace("..","",$filename);
  105. $file = "$cfg_basedir$activepath/$filename";
  106. $content = "";
  107. if(is_file($file))
  108. {
  109. $fp = fopen($file,"r");
  110. $content = fread($fp,filesize($file));
  111. fclose($fp);
  112. $content = dede_htmlspecialchars($content);
  113. }
  114. $contentView = "<textarea name='str' id='str' style='width:99%;height:450px;background:#ffffff;'>$content</textarea>\r\n";
  115. $GLOBALS['filename'] = $filename;
  116. $path_parts = pathinfo($filename);
  117. if ( $path_parts['extension'] == 'php' )
  118. {
  119. $GLOBALS['extension'] = 'text/x-php';
  120. } else if($path_parts['extension'] == 'js'){
  121. $GLOBALS['extension'] = 'text/javascript';
  122. } else if($path_parts['extension'] == 'css'){
  123. $GLOBALS['extension'] = 'text/css';
  124. } else {
  125. $GLOBALS['extension'] = 'text/html';
  126. }
  127. $ctp = new DedeTagParse();
  128. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  129. $ctp->display();
  130. }
  131. /*编辑文件,可视化模式
  132. else if($fmdo=="editview")
  133. {
  134. if(!isset($backurl))
  135. {
  136. $backurl = "";
  137. }
  138. if(!isset($ishead))
  139. {
  140. $ishead = "";
  141. }
  142. $activepath = str_replace("..","",$activepath);
  143. $filename = str_replace("..","",$filename);
  144. $file = "$cfg_basedir$activepath/$filename";
  145. $fp = fopen($file,"r");
  146. @$content = fread($fp,filesize($file));
  147. fclose($fp);
  148. if((eregi("<html",$content) && eregi("<body",$content)) || $ishead == "yes")
  149. {
  150. $contentView = GetEditor("str",$content,"500","Default","string","true");
  151. }
  152. else
  153. {
  154. $contentView = GetEditor("str",$content,"500","Default","string","false");
  155. }
  156. $GLOBALS['filename'] = $filename;
  157. $ctp = new DedeTagParse();
  158. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit_view.htm");
  159. $ctp->display();
  160. }
  161. */
  162. //新建文件
  163. else if($fmdo=="newfile")
  164. {
  165. $content = "";
  166. $GLOBALS['filename'] = "newfile.txt";
  167. $GLOBALS['extension'] = 'text/html';
  168. $contentView = "<textarea id='str' name='str' style='width:99%;height:400'></textarea>\r\n";
  169. $GLOBALS['token'] = make_hash();
  170. $ctp = new DedeTagParse();
  171. $ctp->LoadTemplate(DEDEADMIN."/templets/file_edit.htm");
  172. $ctp->display();
  173. }
  174. //上传文件
  175. else if($fmdo=="upload")
  176. {
  177. $ctp = new DedeTagParse();
  178. $ctp->LoadTemplate(DEDEADMIN."/templets/file_upload.htm");
  179. $ctp->display();
  180. }