SelectPath.asp
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:9k
源码类别:

数据库编程

开发平台:

ASP/ASPX

  1. <% Option Explicit %>
  2. <!--#include file="../../../FS_Inc/Const.asp" -->
  3. <!--#include file="../../../FS_Inc/Function.asp"-->
  4. <!--#include file="../../../FS_InterFace/MF_Function.asp" -->
  5. <%
  6. Dim Conn
  7. MF_Default_Conn
  8. MF_Session_TF
  9. Dim FsoObj,OType
  10. Set FsoObj = Server.CreateObject(G_FS_FSO)
  11. OType = Request("Type")
  12. Dim CurrPath,SubFolderObj,FolderObj,i,FsoItem,sRootDir
  13. Dim ParentPath
  14. if OType <> "" then
  15. Dim Path
  16. if OType = "Del" then
  17. if not MF_Check_Pop_TF("MF027") then Err_Show
  18. Path = Request("Path") 
  19. if Path <> "" then
  20. Path = Server.MapPath(Path)
  21. if FsoObj.FolderExists(Path) = true then FsoObj.DeleteFolder Path
  22. end if
  23. elseif OType = "AddFolder" then
  24. if not MF_Check_Pop_TF("MF028") then Err_Show
  25. Path = Request("Path")
  26. if Path <> "" then
  27. Path = Server.MapPath(Path)
  28. if FsoObj.FolderExists(Path) = True then
  29. Response.Write("<script>alert('目录已经存在');</script>")
  30. else
  31. FsoObj.CreateFolder Path
  32. end if
  33. end if
  34. elseif OType = "FolderReName" then
  35. if not MF_Check_Pop_TF("MF026") then Err_Show
  36. Dim NewPathName,OldPathName,PhysicalPath,FileObj
  37. Path = Request("Path")
  38. if Path <> "" then
  39. NewPathName = Request("NewPathName")
  40. OldPathName = Request("OldPathName")
  41. if (NewPathName <> "") And (OldPathName <> "") then
  42. PhysicalPath = Server.MapPath(Path) & "" & OldPathName
  43. if FsoObj.FolderExists(PhysicalPath) = True then
  44. PhysicalPath = Server.MapPath(Path) & "" & NewPathName
  45. if FsoObj.FolderExists(PhysicalPath) = False then
  46. Set FileObj = FsoObj.GetFolder(Server.MapPath(Path) & "" & OldPathName)
  47. FileObj.Name = NewPathName
  48. Set FileObj = Nothing
  49. end if
  50. end if
  51. end if
  52. end if
  53. end if
  54. end if
  55. CurrPath = trim(Request("CurrPath"))
  56. if CurrPath = "" then:response.Write("错误的参数"):response.end:end if
  57. if CurrPath = "" then
  58. CurrPath = "/"
  59. ParentPath = ""
  60. else
  61. if instr(CurrPath,"/") then ParentPath = Mid(CurrPath,1,InstrRev(CurrPath,"/")-1)
  62. if ParentPath = "" then
  63. ParentPath = "/"
  64. end if
  65. end if
  66. On Error Resume Next
  67. if FsoObj.FolderExists(Server.MapPath(CurrPath))=false then FsoObj.CreateFolder(Server.MapPath(CurrPath))
  68. Set FolderObj = FsoObj.GetFolder(Server.MapPath(CurrPath))
  69. Set SubFolderObj = FolderObj.SubFolders
  70. if err.number>0 then
  71. response.Write "错误,可能是找不到路径,或者你的服务器不支持FSO组件"
  72. response.end
  73. end if
  74. %>
  75. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  76. <html>
  77. <head>
  78. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  79. <title>文件和目录列表</title>
  80. </head>
  81. <style>
  82. .LableItem {
  83. cursor: default;
  84. }
  85. .LableSelectItem {
  86. background-color:highlight;
  87. cursor: default;
  88. color: white;
  89. text-decoration: underline;
  90. }
  91. </style>
  92. <link href="../../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  93. <script language="JavaScript" src="../../../FS_Inc/PublicJS.js"></script>
  94. <script language="JavaScript">
  95. var ObjPopupMenu=window.createPopup();
  96. document.oncontextmenu=new Function("return ShowMouseRightMenu(window.event);");
  97. var DocumentReadyTF=false;
  98. var ContentMenuArray=new Array();
  99. function document.onreadystatechange()
  100. {
  101. if (DocumentReadyTF) return;
  102. InitialClassListContentMenu();
  103. DocumentReadyTF=true;
  104. }
  105. function ShowMouseRightMenu(event)
  106. {
  107. ContentMenuShowEvent();
  108. var width=100;
  109. var height=0;
  110. var lefter=event.clientX;
  111. var topper=event.clientY;
  112. var ObjPopDocument=ObjPopupMenu.document;
  113. var ObjPopBody=ObjPopupMenu.document.body;
  114. var MenuStr='';
  115. if('<%=G_VIRTUAL_ROOT_DIR%>'=='') sRootDir='';else sRootDir='/<%=G_VIRTUAL_ROOT_DIR%>';
  116. for (var i=0;i<ContentMenuArray.length;i++)
  117. {
  118. if (ContentMenuArray[i].ExeFunction=='seperator')
  119. {
  120. MenuStr+=FormatSeperator();
  121. height+=16;
  122. }
  123. else
  124. {
  125. MenuStr+=FormatMenuRow(ContentMenuArray[i].ExeFunction,ContentMenuArray[i].Description,ContentMenuArray[i].EnabledStr);
  126. height+=20;
  127. }
  128. }
  129. MenuStr="<TABLE border=0 cellpadding=0 cellspacing=0 class=Menu width=100>"+MenuStr
  130. MenuStr=MenuStr+"</TABLE>";
  131. ObjPopDocument.open();
  132. ObjPopDocument.write("<head><link href="select_css.css" type="text/css" rel="stylesheet"></head><body scroll="no" onConTextMenu="event.returnValue=false;" onselectstart="event.returnValue=false;">"+MenuStr);
  133. ObjPopDocument.close();
  134. height+=4;
  135. if(lefter+width > document.body.clientWidth) lefter=lefter-width;
  136. ObjPopupMenu.show(lefter, topper, width, height, document.body);
  137. return false;
  138. }
  139. function FormatSeperator()
  140. {
  141. var MenuRowStr="<tr><td height=16 valign=middle><hr></td></tr>";
  142. return MenuRowStr;
  143. }
  144. function FormatMenuRow(MenuOperation,MenuDescription,EnabledStr)
  145. {
  146. var MenuRowStr="<tr "+EnabledStr+"><td align=left height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut'; valign=middle"
  147. if (EnabledStr=='') MenuRowStr+=" onclick=""+MenuOperation+"parent.ObjPopupMenu.hide();">&nbsp;&nbsp;&nbsp;&nbsp;";
  148. else MenuRowStr+=">&nbsp;&nbsp;&nbsp;&nbsp;";
  149. MenuRowStr=MenuRowStr+MenuDescription+"</td></tr>";
  150. return MenuRowStr;
  151. }
  152. function ContentMenuFunction(ExeFunction,Description,EnabledStr)
  153. {
  154. this.ExeFunction=ExeFunction;
  155. this.Description=Description;
  156. this.EnabledStr=EnabledStr;
  157. }
  158. function ContentMenuShowEvent()
  159. {
  160. SelectFolder();
  161. }
  162. function InitialClassListContentMenu()
  163. {
  164. <%Response.write "ContentMenuArray[ContentMenuArray.length]=new ContentMenuFunction(""parent.AddFolderOperation();"",'新建','');"%>
  165. <%Response.write "ContentMenuArray[ContentMenuArray.length]=new ContentMenuFunction(""if (confirm('确定要删除吗?')==true) parent.DelFolderFile();"",'删除','disabled');"%>
  166. <%Response.write "ContentMenuArray[ContentMenuArray.length]=new ContentMenuFunction(""parent.EditFolder();"",'重命名','disabled');"%>
  167. }
  168. </script>
  169. <body topmargin="0" leftmargin="0" onClick="SelectFolder();">
  170. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  171.   <%
  172. if Err.Number = 0 then
  173. for each FsoItem In SubFolderObj
  174. %>
  175.   <tr> 
  176.     <td width="30%"><table border="0" cellspacing="0" cellpadding="0">
  177.         <tr title="双击鼠标进入此目录"> 
  178.           <td><img src="../../Images/Folder/folder.gif" width="20" height="16"></td>
  179.           <td nowrap> <span class="LableItem" Path="<% = FsoItem.name %>" onDblClick="OpenFolder(this);"> 
  180.             <% = FsoItem.name %>
  181.             </span> </td>
  182.         </tr>
  183.       </table></td>
  184.   </tr>
  185.   <%
  186. next
  187. else
  188. %>
  189.   <tr> 
  190.     <td height="20"> <div align="center"> 
  191.         <% = "路径不存在" %>
  192.       </div></td>
  193.   </tr>
  194.   <%
  195. end if
  196. %>
  197. </table>
  198. </body>
  199. </html>
  200. <%
  201. Set FsoObj = Nothing
  202. Set SubFolderObj = Nothing
  203. %>
  204. <script language="JavaScript">
  205. var CurrPath='<% = CurrPath %>';
  206. var SelectedFolder='';
  207. function SelectFolder()
  208. {
  209. Obj=event.srcElement,DisabledContentMenuStr='';
  210. for (var i=0;i<document.all.length;i++)
  211. {
  212. if (document.all(i).className=='LableSelectItem') document.all(i).className='LableItem';
  213. }
  214. if (Obj.Path!=null)
  215. {
  216. Obj.className='LableSelectItem';
  217. SelectedFolder=Obj.Path;
  218. }
  219. else
  220. {
  221. SelectedFolder='';
  222. }
  223. if (SelectedFolder!='')
  224. DisabledContentMenuStr='';
  225. else
  226. DisabledContentMenuStr=',删除,重命名,';
  227. for (var i=0;i<ContentMenuArray.length;i++)
  228. {
  229. if (DisabledContentMenuStr.indexOf(ContentMenuArray[i].Description)!=-1) ContentMenuArray[i].EnabledStr='disabled';
  230. else  ContentMenuArray[i].EnabledStr='';
  231. }
  232. }
  233. function OpenParentFolder(Obj)
  234. {
  235. location.href='SelectPath.asp?CurrPath='+Obj.Path;
  236. SearchOptionExists(parent.document.all.FolderSelectList,Obj.Path);
  237. }
  238. function OpenFolder(Obj)
  239. {
  240. var SubmitPath='';
  241. if (CurrPath=='/') SubmitPath=CurrPath+Obj.Path;
  242. else SubmitPath=CurrPath+'/'+Obj.Path;
  243. location.href='SelectPath.asp?CurrPath='+SubmitPath;
  244. AddFolderList(parent.document.all.FolderSelectList,SubmitPath,SubmitPath);
  245. }
  246. function SelectUpFolder(Obj)
  247. {
  248. for (var i=0;i<document.all.length;i++)
  249. {
  250. if (document.all(i).className=='LableSelectItem') document.all(i).className='LableItem';
  251. }
  252. Obj.className='LableSelectItem';
  253. }
  254. function AddFolderList(SelectObj,Lable,LableContent)
  255. {
  256. var i=0,AddOption;
  257. if (!SearchOptionExists(SelectObj,Lable))
  258. {
  259. AddOption = document.createElement("OPTION");
  260. AddOption.text=Lable;
  261. AddOption.value=LableContent;
  262. SelectObj.add(AddOption);
  263. SelectObj.options(SelectObj.length-1).selected=true;
  264. }
  265. }
  266. function SearchOptionExists(Obj,SearchText)
  267. {
  268. var i;
  269. for(i=0;i<Obj.length;i++)
  270. {
  271. if (Obj.options(i).text==SearchText)
  272. {
  273. Obj.options(i).selected=true;
  274. return true;
  275. }
  276. }
  277. return false;
  278. }
  279. function AddFolderOperation()
  280. {
  281. var ReturnValue=prompt('新建目录名:','');
  282. if ((ReturnValue!='') && (ReturnValue!=null))
  283. window.location.href='?Type=AddFolder&Path='+CurrPath+'/'+ReturnValue+'&CurrPath='+CurrPath;
  284. }
  285. function DelFolderFile()
  286. {
  287. var ReturnValue='';
  288. if (SelectedFolder!='') 
  289. window.location.href='?Type=Del&Path='+CurrPath+'/'+SelectedFolder+'&CurrPath='+CurrPath;
  290. else alert('请选择要删除的目录');
  291. }
  292. function EditFolder()
  293. {
  294. if (SelectedFolder!='')
  295. {
  296. var ReturnValue=prompt('修改的目录名:',SelectedFolder);
  297. if ((ReturnValue!='') && (ReturnValue!=null))
  298. window.location.href='?Type=FolderReName&Path='+CurrPath+'&CurrPath='+CurrPath+'&OldPathName='+SelectedFolder+'&NewPathName='+ReturnValue;
  299. }
  300. else alert('请填写要更名的目录名称');
  301. }
  302. </script>