刷一次變一次圖的ASP代碼
發(fā)布時間:2008-07-28 閱讀數: 次 來源:網樂原科技
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'----------------------------------------------------------------------------------------
'轉發(fā)時請保留松饜畔?這段聲明不并會影響你的顯示速度!
'************************* 隨機圖片顯示 ****************************
'使用實例:img.asp?list=圖片存放目錄
'使用注意:圖片目錄放于本文件同目錄下!需要FSO支持!
'說明:只要將變化圖片放于一個目錄下,修改下面程序的(需要修改的地方)成你的目錄名稱!
上傳本程序和圖片文件夾到同一目錄下,在發(fā)帖時候使用UBB代碼形如:即可!
'----------------------------------------------------------------------------------------
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,2004528115924.htm,address,str
list = trim(Request.QueryString("list"))
if list = "" then
Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"img.asp?list=(需要修改的地方)"
Response.End()
end if
2004528115924.htm = ShowFileList("./"&list&"/")
if 2004528115924.htm = "NO" then
Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!"
Response.End()
end if
if 2004528115924.htm = "" then
Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!"
Response.End()
end if
str = right(2004528115924.htm,3)
if str<>"jpg" and str<>"gif" then
2004528115924.htm = "erro.gif"
end if
address = AllPath&list&"/"
address = address&2004528115924.htm
%>
<%Response.redirect(address)%>