sunlei 发表于 2005 年 3 月 12 日 03:30:16

刷一次变一次图的ASP代码

<%@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 = "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

address = AllPath&list&"/"
address = address&filename
%>
<%Response.redirect(address)%>

779 发表于 2005 年 3 月 12 日 03:31:30

我有PHP的!但不方便拿出来!呵呵

无糖咖啡 发表于 2005 年 3 月 12 日 04:12:13

下面是引用779于2005-03-12 03:31发表的:
我有PHP的!但不方便拿出来!呵呵
为啥?

发表于 2005 年 3 月 12 日 06:47:09

收藏 3Q3Q3Q

恢复自我 发表于 2005 年 3 月 12 日 08:33:39

不错哦

华山三少 发表于 2005 年 3 月 12 日 10:15:40

不错的一个程序

我老早就想找了

3Q

sunlei 发表于 2005 年 3 月 12 日 03:30:16

刷一次变一次图的ASP代码

<%@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 = "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

address = AllPath&list&"/"
address = address&filename
%>
<%Response.redirect(address)%>
页: [1]
查看完整版本: 刷一次变一次图的ASP代码