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

数据库编程

开发平台:

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. <!--#include file="../lib/strlib.asp" -->
  6. <!--#include file="../lib/UserCheck.asp" -->
  7. <%
  8. Response.Buffer = True
  9. Response.Expires = -1
  10. Response.ExpiresAbsolute = Now() - 1
  11. Response.Expires = 0
  12. Response.CacheControl = "no-cache"
  13. if trim(Request.QueryString("f_UserNumber"))="" then  response.Write("登陆过期,或者参数不正确"):response.end
  14. if trim(Request.QueryString("f_UserNumber"))<>Fs_User.UserNumber then  response.Write("错误参数"):response.end
  15. Dim TypeSql,RsTypeObj,LableSql,RsLableObj
  16. Dim CurrPath,FsoObj,SubFolderObj,FolderObj,FileObj,i,FsoItem,OType
  17. Dim ParentPath,FileExtName,AllowShowExtNameStr,str_CurrPath
  18. Dim ShowVirtualPath,sRootDir 
  19. if G_VIRTUAL_ROOT_DIR<>"" then sRootDir="/" & G_VIRTUAL_ROOT_DIR else sRootDir=""
  20. CurrPath = Replace("/"&G_VIRTUAL_ROOT_DIR &"/"&G_USERFILES_DIR&"/"&Session("FS_UserNumber"),"//","/")
  21. Set FsoObj = Server.CreateObject(G_FS_FSO)
  22. OType = Request("Type")
  23. if OType <> "" then
  24. Dim Path,PhysicalPath
  25. if OType = "DelFolder" then
  26. Path = Request("Path") 
  27. if Path <> "" then
  28. Path = Server.MapPath(Path)
  29. if FsoObj.FolderExists(Path) = true then FsoObj.DeleteFolder Path
  30. end if
  31. elseif OType = "DelFile" then
  32. Dim DelFileName
  33. Path = Request("Path") 
  34. DelFileName = Request("FileName") 
  35. if (DelFileName <> "") And (Path <> "") then
  36. Path = Server.MapPath(Path)
  37. if FsoObj.FileExists(Path & "" & DelFileName) = true then FsoObj.DeleteFile Path & "" & DelFileName
  38. end if
  39. elseif OType = "AddFolder" then
  40. Path = Request("Path")
  41. if Path <> "" then
  42. Path = Server.MapPath(Path)
  43. if FsoObj.FolderExists(Path) = True then
  44. Response.Write("<script>alert('目录已经存在');</script>")
  45. else
  46. FsoObj.CreateFolder Path
  47. end if
  48. end if
  49. elseif OType = "FileReName" then
  50. Dim NewFileName,OldFileName
  51. Path = Request("Path")
  52. if Path <> "" then
  53. NewFileName = Request("NewFileName")
  54. OldFileName = Request("OldFileName")
  55. if (NewFileName <> "") And (OldFileName <> "") then
  56. PhysicalPath = Server.MapPath(Path) & "" & OldFileName
  57. if FsoObj.FileExists(PhysicalPath) = True then
  58. PhysicalPath = Server.MapPath(Path) & "" & NewFileName
  59. if FsoObj.FileExists(PhysicalPath) = False then
  60. Set FileObj = FsoObj.GetFile(Server.MapPath(Path) & "" & OldFileName)
  61. FileObj.Name = NewFileName
  62. Set FileObj = Nothing
  63. end if
  64. end if
  65. end if
  66. end if
  67. elseif OType = "FolderReName" then
  68. Dim NewPathName,OldPathName
  69. Path = Request("Path")
  70. if Path <> "" then
  71. NewPathName = Request("NewPathName")
  72. OldPathName = Request("OldPathName")
  73. if (NewPathName <> "") And (OldPathName <> "") then
  74. PhysicalPath = Server.MapPath(Path) & "" & OldPathName
  75. if FsoObj.FolderExists(PhysicalPath) = True then
  76. PhysicalPath = Server.MapPath(Path) & "" & NewPathName
  77. if FsoObj.FolderExists(PhysicalPath) = False then
  78. Set FileObj = FsoObj.GetFolder(Server.MapPath(Path) & "" & OldPathName)
  79. FileObj.Name = NewPathName
  80. Set FileObj = Nothing
  81. end if
  82. end if
  83. end if
  84. end if
  85. end if
  86. end if
  87. ShowVirtualPath = Request("ShowVirtualPath")
  88. AllowShowExtNameStr = "jpg,txt,gif,bmp,png"
  89. CurrPath = Replace(Request("CurrPath"),"//","/")
  90. if CurrPath = "" then
  91. CurrPath = Replace("/"&G_VIRTUAL_ROOT_DIR &"/"&G_USERFILES_DIR&"/"&Session("FS_UserNumber"),"//","/")
  92. ParentPath = ""
  93. else
  94. ParentPath = Mid(CurrPath,1,InstrRev(CurrPath,"/")-1)
  95. if ParentPath = "" then
  96. CurrPath = Replace("/"&G_VIRTUAL_ROOT_DIR &"/"&G_USERFILES_DIR&"/"&Session("FS_UserNumber"),"//","/")
  97. end if
  98. end if
  99. dim CurrPath1
  100. CurrPath1 = Server.MapPath(replace(Replace(CurrPath,"\",""),"/",""))
  101. if FsoObj.FolderExists(CurrPath1) = false then FsoObj.CreateFolder CurrPath1
  102. Set FolderObj = FsoObj.GetFolder(Server.MapPath(CurrPath))
  103. Set SubFolderObj = FolderObj.SubFolders
  104. Set FileObj = FolderObj.Files
  105. Function CheckFileShowTF(AllowShowExtNameStr,ExtName)
  106. if ExtName="" then
  107. CheckFileShowTF = False
  108. else
  109. if InStr(1,AllowShowExtNameStr,ExtName) = 0 then
  110. CheckFileShowTF = False
  111. else
  112. CheckFileShowTF = True
  113. end if
  114. end if
  115. End Function
  116. %>
  117. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  118. <html>
  119. <head>
  120. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  121. <title>文件和目录列表</title>
  122. </head>
  123. <style>
  124. .TempletItem {
  125. cursor: default;
  126. }
  127. .TempletSelectItem {
  128. background-color:highlight;
  129. cursor: default;
  130. color: white;
  131. }
  132. </style>
  133. <link href="../../<% = G_USER_DIR %>/images/skin/Css_<%=Request.Cookies("FoosunUserCookies")("UserLogin_Style_Num")%>/<%=Request.Cookies("FoosunUserCookies")("UserLogin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  134. <script language="JavaScript">
  135. var ObjPopupMenu=window.createPopup();
  136. document.oncontextmenu=new Function("return ShowMouseRightMenu(window.event);");
  137. function ShowMouseRightMenu(event)
  138. {
  139. ContentMenuShowEvent();
  140. var width=100;
  141. var height=0;
  142. var lefter=event.clientX;
  143. var topper=event.clientY;
  144. var ObjPopDocument=ObjPopupMenu.document;
  145. var ObjPopBody=ObjPopupMenu.document.body;
  146. var MenuStr='';
  147. for (var i=0;i<ContentMenuArray.length;i++)
  148. {
  149. if (ContentMenuArray[i].ExeFunction=='seperator')
  150. {
  151. MenuStr+=FormatSeperator();
  152. height+=16;
  153. }
  154. else
  155. {
  156. MenuStr+=FormatMenuRow(ContentMenuArray[i].ExeFunction,ContentMenuArray[i].Description,ContentMenuArray[i].EnabledStr);
  157. height+=20;
  158. }
  159. }
  160. MenuStr="<TABLE border=0 cellpadding=0 cellspacing=0 class=Menu width=100>"+MenuStr
  161. MenuStr=MenuStr+"</TABLE>";
  162. ObjPopDocument.open();
  163. 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);
  164. ObjPopDocument.close();
  165. height+=4;
  166. if(lefter+width > document.body.clientWidth) lefter=lefter-width;
  167. ObjPopupMenu.show(lefter, topper, width, height, document.body);
  168. return false;
  169. }
  170. function FormatSeperator()
  171. {
  172. var MenuRowStr="<tr><td height=16 valign=middle><hr></td></tr>";
  173. return MenuRowStr;
  174. }
  175. function FormatMenuRow(MenuOperation,MenuDescription,EnabledStr)
  176. {
  177. var MenuRowStr="<tr "+EnabledStr+"><td align=left height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut'; valign=middle"
  178. if (EnabledStr=='') MenuRowStr+=" onclick=""+MenuOperation+"parent.ObjPopupMenu.hide();">&nbsp;&nbsp;&nbsp;&nbsp;";
  179. else MenuRowStr+=">&nbsp;&nbsp;&nbsp;&nbsp;";
  180. MenuRowStr=MenuRowStr+MenuDescription+"</td></tr>";
  181. return MenuRowStr;
  182. }
  183. </script>
  184. <body topmargin="0" leftmargin="0" onClick="SelectFolder();"  class="hback">
  185. <table width="99%" border="0" align="center" cellpadding="2" cellspacing="0"  class="hback">
  186.   <%
  187. if  lcase(Trim(CurrPath))<>  lcase(Trim(str_CurrPath)) then  
  188. %>
  189.   <tr title="上级目录<% = ParentPath %>" onClick="SelectUpFolder(this);" Path="<% = ParentPath %>" onDblClick="OpenParentFolder(this);"> 
  190.     <td colspan="2"> <table width="62" border="0" cellpadding="0" cellspacing="0">
  191.         <tr> 
  192.           <td width="21"><font color="#FFFFFF"><img src="../Images/folder.gif" width="20" height="16"></font></td>
  193.           <td width="41">...</td>
  194.         </tr>
  195.       </table></td>
  196.     <td width="35%"><div align="center"><font color="#FFFFFF">-</font></div></td>
  197.     <td width="17%"><div align="center"><font color="#FFFFFF">-</font></div></td>
  198.   </tr>
  199.   <%
  200. end if
  201. for each FsoItem In SubFolderObj
  202. %>
  203.   <tr> 
  204.     <td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
  205.         <tr title="双击鼠标进入此目录"> 
  206.           <td valign="top"><img src="../Images/folder.gif" width="20" height="16"></td>
  207.           <td valign="bottom"> <span class="TempletItem" Path="<% = FsoItem.name %>" onClick="ClearPicUrl()"; onDblClick="OpenFolder(this);"> 
  208.             <% = FsoItem.name %>
  209.             </span> </td>
  210.         </tr>
  211.       </table></td>
  212.     <td><div align="left">文件夹</div></td>
  213.     <td><div align="center"> 
  214.         <% = FsoItem.Size %>
  215.       </div></td>
  216.   </tr>
  217.   <%
  218. next
  219. for each FsoItem In FileObj
  220. FileExtName = LCase(Mid(FsoItem.name,InstrRev(FsoItem.name,".")+1))
  221. if True then 'CheckFileShowTF(AllowShowExtNameStr,FileExtName) = 
  222. %>
  223.   <tr title="双击鼠标选择此文件"> 
  224.     <td width="2%"> <span class="TempletItem" File="<% = FsoItem.name %>" onDblClick="SetFile(this);" onClick="SelectFile(this);"> 
  225.       <img src="../Images/files.gif" width="16" height="16"> </span> </td>
  226.     <td width="46%"><span class="TempletItem" File="<% = FsoItem.name %>" onDblClick="SetFile(this);" onClick="SelectFile(this);">
  227.       <% = FsoItem.name %>
  228.       </span></td>
  229.     <td> <div align="left"> 
  230.         <%if len(FsoItem.Type)>18 then:response.Write left(FsoItem.Type,18)&"...":else:response.Write FsoItem.Type:end if%>
  231.       </div></td>
  232.     <td><div align="center"> 
  233.         <%
  234. if FsoItem.Size>1000 then
  235. Response.Write FormatNumber(FsoItem.Size/1024,1,-1) &"KB"
  236.         Else
  237. Response.Write FsoItem.Size &"字节"
  238. End if
  239. %>
  240.       </div></td>
  241.   </tr>
  242.   <%
  243.    end if
  244. next
  245. %>
  246. </table>
  247. </body>
  248. </html>
  249. <%
  250. Set FsoObj = Nothing
  251. Set SubFolderObj = Nothing
  252. Set FileObj = Nothing
  253. %>
  254. <script language="JavaScript">
  255. var CurrPath='<% = CurrPath %>';
  256. var G_VIRTUAL_ROOT_DIR='<% = G_VIRTUAL_ROOT_DIR %>';
  257. var ShowVirtualPath='<% = ShowVirtualPath %>';
  258. var SelectedObj=null;
  259. var ContentMenuArray=new Array();
  260. DocumentReadyTF=false;
  261. function document.onreadystatechange()
  262. {
  263. if (DocumentReadyTF) return;
  264. InitialClassListContentMenu();
  265. DocumentReadyTF=true;
  266. }
  267. function ContentMenuFunction(ExeFunction,Description,EnabledStr)
  268. {
  269. this.ExeFunction=ExeFunction;
  270. this.Description=Description;
  271. this.EnabledStr=EnabledStr;
  272. }
  273. function ContentMenuShowEvent()
  274. {
  275. SelectFolder();
  276. }
  277. function InitialClassListContentMenu()
  278. {
  279. <%Response.write "ContentMenuArray[ContentMenuArray.length]=new ContentMenuFunction(""parent.AddFolderOperation();"",'新建目录','');"%>
  280. <%Response.write "ContentMenuArray[ContentMenuArray.length]=new ContentMenuFunction(""if (confirm('确定要删除吗?')==true) parent.DelFolderFile();"",'删除','disabled');"%>
  281. //此处是否允许管理员重命名文件名,如果开启重命名有风险,请小心使用。
  282. //<%Response.write "ContentMenuArray[ContentMenuArray.length]=new ContentMenuFunction(""parent.EditFolder();"",'重命名','disabled');"%>
  283. }
  284. function SelectFolder()
  285. {
  286. Obj=event.srcElement,DisabledContentMenuStr='';
  287. if (SelectedObj!=null) SelectedObj.className='TempletItem';
  288. if ((Obj.Path!=null)||(Obj.File!=null))
  289. {
  290. Obj.className='TempletSelectItem';
  291. SelectedObj=Obj;
  292. }
  293. else SelectedObj=null;
  294. if (SelectedObj!=null) DisabledContentMenuStr='';
  295. else DisabledContentMenuStr=',删除,重命名,';
  296. for (var i=0;i<ContentMenuArray.length;i++)
  297. {
  298. if (DisabledContentMenuStr.indexOf(ContentMenuArray[i].Description)!=-1) ContentMenuArray[i].EnabledStr='disabled';
  299. else  ContentMenuArray[i].EnabledStr='';
  300. }
  301. }
  302. function SelectFile(Obj)
  303. {
  304. for (var i=0;i<document.all.length;i++)
  305. {
  306. if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
  307. }
  308. Obj.className='TempletSelectItem';
  309. PreviewFile(Obj);
  310. }
  311. function OpenParentFolder(Obj)
  312. {
  313. location.href='FolderImageList.asp?f_UserNumber=<%=session("FS_UserNumber")%>&CurrPath='+Obj.Path;
  314. SearchOptionExists(parent.document.all.FolderSelectList,Obj.Path);
  315. }
  316. function OpenFolder(Obj)
  317. {
  318. var SubmitPath='';
  319. if (CurrPath=='/') SubmitPath=CurrPath+Obj.Path;
  320. else SubmitPath=CurrPath+'/'+Obj.Path;
  321. location.href='FolderImageList.asp?f_UserNumber=<%=session("FS_UserNumber")%>&CurrPath='+SubmitPath;
  322. AddFolderList(parent.document.all.FolderSelectList,SubmitPath,SubmitPath);
  323. }
  324. function SelectUpFolder(Obj)
  325. {
  326. for (var i=0;i<document.all.length;i++)
  327. {
  328. if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
  329. }
  330. Obj.className='TempletSelectItem';
  331. parent.UserUrl.value='';
  332. }
  333. function PreviewFile(Obj)
  334. {
  335. var Url='';
  336. var Path=escape();
  337. if (CurrPath=='/') Path=escape(CurrPath+Obj.File);
  338. else Path=escape(CurrPath+'/'+Obj.File);
  339. Url='PreviewImage.asp?FilePath='+Path;
  340. if (G_VIRTUAL_ROOT_DIR!='')
  341. Path=Path.slice(G_VIRTUAL_ROOT_DIR.length+1)
  342. parent.UserUrl.value=Path;
  343. parent.frames["PreviewArea"].location=Url.toLowerCase();
  344. }
  345. function AddFolderList(SelectObj,Lable,LableContent)
  346. {
  347. var i=0,AddOption;
  348. if (!SearchOptionExists(SelectObj,Lable))
  349. {
  350. AddOption = document.createElement("OPTION");
  351. AddOption.text=Lable;
  352. AddOption.value=LableContent;
  353. SelectObj.add(AddOption);
  354. SelectObj.options(SelectObj.length-1).selected=true;
  355. }
  356. }
  357. function SearchOptionExists(Obj,SearchText)
  358. {
  359. var i;
  360. for(i=0;i<Obj.length;i++)
  361. {
  362. if (Obj.options(i).text==SearchText)
  363. {
  364. Obj.options(i).selected=true;
  365. return true;
  366. }
  367. }
  368. return false;
  369. }
  370. function SetFile(Obj)
  371. {
  372. //if (ShowVirtualPath=='')
  373. //{
  374. var PathInfo='',TempPath='';
  375. if (G_VIRTUAL_ROOT_DIR!='')
  376. {
  377. TempPath=CurrPath;
  378. PathInfo=TempPath.substr(TempPath.indexOf(G_VIRTUAL_ROOT_DIR)+G_VIRTUAL_ROOT_DIR.length);
  379. }
  380. else
  381. {
  382. PathInfo=CurrPath;
  383. }
  384. //}
  385. //else PathInfo=CurrPath;
  386. if (CurrPath=='/') window.returnValue=PathInfo+Obj.File;
  387. else window.returnValue=PathInfo+'/'+Obj.File;
  388. window.close();
  389. }
  390. window.onunload=CheckReturnValue;
  391. function CheckReturnValue()
  392. {
  393. if (typeof(window.returnValue)!='string') window.returnValue='';
  394. }
  395. function AddFolderOperation()
  396. {
  397. var ReturnValue=prompt('新建目录名:','');
  398. if ((ReturnValue!='') && (ReturnValue!=null))
  399. window.location.href='?f_UserNumber=<%=session("FS_UserNumber")%>&Type=AddFolder&Path='+CurrPath+'/'+ReturnValue+'&CurrPath='+CurrPath;
  400. }
  401. function DelFolderFile()
  402. {
  403. if (SelectedObj!=null)
  404. {
  405. if (SelectedObj.Path!=null) window.location.href='?f_UserNumber=<%=session("FS_UserNumber")%>&Type=DelFolder&Path='+CurrPath+'/'+SelectedObj.Path+'&CurrPath='+CurrPath;
  406. if (SelectedObj.File!=null) window.location.href='?f_UserNumber=<%=session("FS_UserNumber")%>&Type=DelFile&Path='+CurrPath+'&FileName='+SelectedObj.File+'&CurrPath='+CurrPath;
  407. }
  408. else alert('请选择要删除的目录');
  409. }
  410. function EditFolder()
  411. {
  412. var ReturnValue='';
  413. if (SelectedObj!=null)
  414. {
  415. if (SelectedObj.Path!=null)
  416. {
  417. ReturnValue=prompt('修改的名称:',SelectedObj.Path);
  418. if ((ReturnValue!='') && (ReturnValue!=null)) window.location.href='?f_UserNumber=<%=session("FS_UserNumber")%>&Type=FolderReName&Path='+CurrPath+'&CurrPath='+CurrPath+'&OldPathName='+SelectedObj.Path+'&NewPathName='+ReturnValue;
  419. }
  420. if (SelectedObj.File!=null)
  421. {
  422. ReturnValue=prompt('修改的名称:',SelectedObj.File);
  423. if ((ReturnValue!='') && (ReturnValue!=null)) window.location.href='?f_UserNumber=<%=session("FS_UserNumber")%>&Type=FileReName&Path='+CurrPath+'&CurrPath='+CurrPath+'&OldFileName='+SelectedObj.File+'&NewFileName='+ReturnValue;
  424. }
  425. }
  426. else alert('请填写要更名的目录名称');
  427. }
  428. function ClearPicUrl()
  429. {
  430. parent.UserUrl.value='';
  431. }
  432. </script>