Random | display | random <% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
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 "This page needs the correct parameter introduction, you are missing the related parameter!" The correct format is as follows: "&AllPath& img.asp?list= picture Storage Directory"
Response.End ()
End If
filename = Showfilelist ("./" &list& "/")
if filename = "NO" Then
Response.Write "The directory you specified <b>" &list& "</b> does not exist, please specify it again! "
Response.End ()
End If
if filename = "" Then
Response.Write "Your specified directory <b>" &list& "</b> no related picture files exist, please reassign! "
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)%>