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

数据库编程

开发平台:

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