<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% '---------------------------------------------------------------------------------------- '转发时请保留此声明信息,这段声明不并会影响你的显示速度! '*********************** 随机图片显示 ************************* '代码分析收集: netm1.126.com '时间:2005-07-01 '使用实例:img.asp?list=图片存放目录 '使用注意:图片目录放于本文件同目录下!需要FSO支持! ---------------------------------------------------------------------------------------- Function AllPath() Dim Domain,GFilePath Domain = Request.ServerVariables("SERVER_NAME") GFilePath = Request.ServerVariables("PATH_INFO") GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/"))) AllPath = "http://"&Domain&GFilePath 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
Sorry, the comment you entered is too long. Please shorten it.
You didn't enter anything. Please try again.
Sorry, we can't add your comment right now. Please try again later.
To add a comment, you need permission from your parent. Ask for permission
Your parent has turned off comments.
Sorry, we can't delete your comment right now. Please try again later.
You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
Complete the security check below to finish leaving your comment.
The characters you type in the security check must match the characters in the picture or audio.
To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in