<
%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% ---------------------------------------------------------------------------------------- 轉發時請保留鬆饜畔?這段聲明不併會影響你的顯示速度! ************************* 隨機圖片顯示 **************************** 使用實例:img.asp?list=圖片存放目錄 使用注意:圖片目錄放於本文件同目錄下!須要FSO支持! 說明:只要將變化圖片放於一個目錄下,修改下面程序的(須要修改的地方)成你的目錄名稱! 上傳本程序和圖片文件夾到同一目錄下,在發帖時候使用UBB代碼形如:便可! ---------------------------------------------------------------------------------------- Function AllPath() Dim Domain,GFilePath Domain = Request.ServerVariables("SERVER_NAME") GFilePath = Request.ServerVariables("PATH_INFO") GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/"))) AllPath = "<a href='http://"&domain&gfilepath /' target="_blank" >http://"&Domain&GFilePath </A> End Function Function ShowFileList(folderspec) Dim Path,objFSO,objFolder,count,objFile,nume,S Path = Server.MapPath(folderspec) Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(Path) Then Set objFolder = objFSO.GetFolder(Path) count = 0 For Each objFile in objFolder.Files count = count+1 Next randomize nume = Int((count*rnd)+1) S = 0 ShowFileList = "" For Each objFile in objFolder.Files S = S + 1 If S = nume Then ShowFileList = objFile.Name Exit For End If Next Set objFolder = Nothing Else ShowFileList = "NO" End If Set objFSO = Nothing End Function Dim list,filename,address,str list = trim(Request.QueryString("list")) if list = "" then Response.write "本頁須要正確參數引入,您缺乏相關的參數!正確格式以下:"&AllPath&"img.asp?list=(須要修改的地方)" Response.End() end if filename = ShowFileList("./"&list&"/") if filename = "NO" then Response.write "您指定的目錄<b>"&list&"</b>不存在,請從新指定!" Response.End() end if if filename = "" then Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請從新指定!" Response.End() end if str = right(filename,3) if str<>"jpg" and str<>"gif" then filename = "erro.gif" end if address = AllPath&list&"/" address = address&filename %> <%Response.redirect(address)%>