刷一次變一次圖的ASP代碼

來源:互聯網
上載者:User
<%@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)%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.