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

数据库编程

开发平台:

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. Dim TypeSql,RsTypeObj,LableSql,RsLableObj
  8. MF_Default_Conn
  9. MF_Session_TF
  10. if not MF_Check_Pop_TF("MF025") then Err_Show
  11. Dim CurrPath,FsoObj,SubFolderObj,FolderObj,FileObj,i,FsoItem,OType
  12. Dim ParentPath,FileExtName,AllowShowExtNameStr,str_CurrPath
  13. Dim ShowVirtualPath,sRootDir 
  14. if G_VIRTUAL_ROOT_DIR<>"" then sRootDir="/" & G_VIRTUAL_ROOT_DIR else sRootDir=""
  15. if Session("Admin_Is_Super") = 1 then
  16. str_CurrPath = sRootDir &"/"&G_UP_FILES_DIR
  17. Else
  18. str_CurrPath = Replace(sRootDir &"/"&G_UP_FILES_DIR&"/adminfiles/"&Session("Admin_Name"),"//","/")
  19. End if
  20. Set FsoObj = Server.CreateObject(G_FS_FSO)
  21. OType = Request("Type")
  22. if OType <> "" then
  23. Dim Path,PhysicalPath
  24. if OType = "DelFolder" then
  25. Path = Request("Path") 
  26. if Path <> "" then
  27. Path = Server.MapPath(Path)
  28. if FsoObj.FolderExists(Path) = true then FsoObj.DeleteFolder Path
  29. end if
  30. elseif OType = "DelFile" then
  31. Dim DelFileName
  32. Path = Request("Path") 
  33. DelFileName = Request("FileName") 
  34. if (DelFileName <> "") And (Path <> "") then
  35. Path = Server.MapPath(Path)
  36. if FsoObj.FileExists(Path & "" & DelFileName) = true then FsoObj.DeleteFile Path & "" & DelFileName
  37. end if
  38. elseif OType = "AddFolder" then
  39. Path = Request("Path")
  40. if Path <> "" then
  41. Path = Server.MapPath(Path)
  42. if FsoObj.FolderExists(Path) = True then
  43. Response.Write("<script>alert('目录已经存在');</script>")
  44. else
  45. FsoObj.CreateFolder Path
  46. end if
  47. end if
  48. elseif OType = "FileReName" then
  49. Dim NewFileName,OldFileName
  50. Path = Request("Path")
  51. if Path <> "" then
  52. NewFileName = Request("NewFileName")
  53. OldFileName = Request("OldFileName")
  54. if (NewFileName <> "") And (OldFileName <> "") then
  55. PhysicalPath = Server.MapPath(Path) & "" & OldFileName
  56. if FsoObj.FileExists(PhysicalPath) = True then
  57. PhysicalPath = Server.MapPath(Path) & "" & NewFileName
  58. if FsoObj.FileExists(PhysicalPath) = False then
  59. Set FileObj = FsoObj.GetFile(Server.MapPath(Path) & "" & OldFileName)
  60. FileObj.Name = NewFileName
  61. Set FileObj = Nothing
  62. end if
  63. end if
  64. end if
  65. end if
  66. elseif OType = "FolderReName" then
  67. Dim NewPathName,OldPathName
  68. Path = Request("Path")
  69. if Path <> "" then
  70. NewPathName = Request("NewPathName")
  71. OldPathName = Request("OldPathName")
  72. if (NewPathName <> "") And (OldPathName <> "") then
  73. PhysicalPath = Server.MapPath(Path) & "" & OldPathName
  74. if FsoObj.FolderExists(PhysicalPath) = True then
  75. PhysicalPath = Server.MapPath(Path) & "" & NewPathName
  76. if FsoObj.FolderExists(PhysicalPath) = False then
  77. Set FileObj = FsoObj.GetFolder(Server.MapPath(Path) & "" & OldPathName)
  78. FileObj.Name = NewPathName
  79. Set FileObj = Nothing
  80. end if
  81. end if
  82. end if
  83. end if
  84. end if
  85. end if
  86. ShowVirtualPath = Request("ShowVirtualPath")
  87. AllowShowExtNameStr = "jpg,txt,gif,bmp,png"
  88. CurrPath = Replace(Request("CurrPath"),"//","/")
  89. if G_VIRTUAL_ROOT_DIR <>"" then
  90. if Trim(CurrPath) = "/"  or  Trim(CurrPath) =G_UP_FILES_DIR &"/"  or lcase(Trim(CurrPath)) = lcase(G_UP_FILES_DIR &"/Foosun_Data") then
  91. Response.Write("非法参数")
  92. Response.end
  93. End if
  94. Else
  95. if Trim(CurrPath) = "/"  or lcase(Trim(CurrPath)) = lcase("/Foosun_Data") then
  96. Response.Write("非法参数")
  97. Response.end
  98. End if
  99. End if
  100. if CurrPath = "" then
  101. CurrPath = "/" & G_VIRTUAL_ROOT_DIR&"/adminfiles/"&Session("Admin_Name")
  102. ParentPath = ""
  103. else
  104. ParentPath = Mid(CurrPath,1,InstrRev(CurrPath,"/")-1)
  105. if ParentPath = "" then
  106. ParentPath =sRootDir&"/adminfiles/"&Session("Admin_Name")
  107. end if
  108. end if
  109. Set FolderObj = FsoObj.GetFolder(Server.MapPath(CurrPath))
  110. Set SubFolderObj = FolderObj.SubFolders
  111. Set FileObj = FolderObj.Files
  112. Function CheckFileShowTF(AllowShowExtNameStr,ExtName)
  113. if ExtName="" then
  114. CheckFileShowTF = False
  115. else
  116. if InStr(1,AllowShowExtNameStr,ExtName) = 0 then
  117. CheckFileShowTF = False
  118. else
  119. CheckFileShowTF = True
  120. end if
  121. end if
  122. End Function
  123. %>
  124. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  125. <html>
  126. <head>
  127. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  128. <title>文件和目录列表</title>
  129. </head>
  130. <style>
  131. .TempletItem {
  132. cursor: default;
  133. }
  134. .TempletSelectItem {
  135. background-color:highlight;
  136. cursor: default;
  137. color: white;
  138. }
  139. </style>
  140. <link href="../../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  141. <script language="JavaScript">
  142. var ObjPopupMenu=window.createPopup();
  143. document.oncontextmenu=new Function("return ShowMouseRightMenu(window.event);");
  144. function ShowMouseRightMenu(event)
  145. {
  146. ContentMenuShowEvent();
  147. var width=100;
  148. var height=0;
  149. var lefter=event.clientX;
  150. var topper=event.clientY;
  151. var ObjPopDocument=ObjPopupMenu.document;
  152. var ObjPopBody=ObjPopupMenu.document.body;
  153. var MenuStr='';
  154. for (var i=0;i<ContentMenuArray.length;i++)
  155. {
  156. if (ContentMenuArray[i].ExeFunction=='seperator')
  157. {
  158. MenuStr+=FormatSeperator();
  159. height+=16;
  160. }
  161. else
  162. {
  163. MenuStr+=FormatMenuRow(ContentMenuArray[i].ExeFunction,ContentMenuArray[i].Description,ContentMenuArray[i].EnabledStr);
  164. height+=20;
  165. }
  166. }
  167. MenuStr="<TABLE border=0 cellpadding=0 cellspacing=0 class=Menu width=100>"+MenuStr
  168. MenuStr=MenuStr+"</TABLE>";
  169. ObjPopDocument.open();
  170. 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);
  171. ObjPopDocument.close();
  172. height+=4;
  173. if(lefter+width > document.body.clientWidth) lefter=lefter-width;
  174. ObjPopupMenu.show(lefter, topper, width, height, document.body);
  175. return false;
  176. }
  177. function FormatSeperator()
  178. {
  179. var MenuRowStr="<tr><td height=16 valign=middle><hr></td></tr>";
  180. return MenuRowStr;
  181. }
  182. function FormatMenuRow(MenuOperation,MenuDescription,EnabledStr)
  183. {
  184. var MenuRowStr="<tr "+EnabledStr+"><td align=left height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut'; valign=middle"
  185. if (EnabledStr=='') MenuRowStr+=" onclick=""+MenuOperation+"parent.ObjPopupMenu.hide();">&nbsp;&nbsp;&nbsp;&nbsp;";
  186. else MenuRowStr+=">&nbsp;&nbsp;&nbsp;&nbsp;";
  187. MenuRowStr=MenuRowStr+MenuDescription+"</td></tr>";
  188. return MenuRowStr;
  189. }
  190. </script>
  191. <body topmargin="0" leftmargin="0" onClick="SelectFolder();">
  192. <table width="99%" border="0" align="center" cellpadding="2" cellspacing="0">
  193.   <%
  194. if  lcase(Trim(CurrPath))<>  lcase(Trim(str_CurrPath)) then  
  195. %>
  196.   <tr title="上级目录<% = ParentPath %>" onClick="SelectUpFolder(this);" Path="<% = ParentPath %>" onDblClick="OpenParentFolder(this);"> 
  197.     <td> <table width="62" border="0" cellpadding="0" cellspacing="0">
  198.         <tr> 
  199.           <td width="21"><font color="#FFFFFF"><img src="../../Images/Folder/folder.gif" width="20" height="16"></font></td>
  200.           <td width="41">...</td>
  201.         </tr>
  202.       </table></td>
  203.     <td width="28%"><div align="center"><font color="#FFFFFF">-</font></div></td>
  204.     <td width="23%"><div align="center"><font color="#FFFFFF">-</font></div></td>
  205.   </tr>
  206.   <%
  207. end if
  208. for each FsoItem In SubFolderObj
  209. %>
  210.   <tr> 
  211.     <td width="49%"><table border="0" cellspacing="0" cellpadding="0">
  212.         <tr title="双击鼠标进入此目录"> 
  213.           <td><img src="../../Images/Folder/folder.gif" width="20" height="16"></td>
  214.           <td> <span class="TempletItem" Path="<% = FsoItem.name %>" onClick="ClearPicUrl()"; onDblClick="OpenFolder(this);"> 
  215.             <% = FsoItem.name %>
  216.             </span> </td>
  217.         </tr>
  218.       </table></td>
  219.     <td><div align="center">文件夹</div></td>
  220.     <td><div align="center"> 
  221.         <% = FsoItem.Size %>
  222.       </div></td>
  223.   </tr>
  224.   <%
  225. next
  226. for each FsoItem In FileObj
  227. FileExtName = LCase(Mid(FsoItem.name,InstrRev(FsoItem.name,".")+1))
  228. if True then 'CheckFileShowTF(AllowShowExtNameStr,FileExtName) = 
  229. %>
  230.   <tr title="双击鼠标选择此文件"> 
  231.     <td> <span class="TempletItem" File="<% = FsoItem.name %>" onDblClick="SetFile(this);" onClick="SelectFile(this);"> 
  232.       <img src="../../Images/FileIcon/gif.gif" width="16" height="16"> 
  233.       <% = FsoItem.name %>
  234.       </span> </td>
  235.     <td><div align="center"> 
  236.         <% = FsoItem.Type %>
  237.       </div></td>
  238.     <td><div align="center"> 
  239.         <% = FsoItem.Size %>
  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. <%if Session("Admin_Is_Super") = 1 then 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?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?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='?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='?Type=DelFolder&Path='+CurrPath+'/'+SelectedObj.Path+'&CurrPath='+CurrPath;
  406. if (SelectedObj.File!=null) window.location.href='?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='?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='?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>