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

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