23
2005
04

ASP 随机显示图片代码(可做论坛头像)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<%

Function getHTTPPage(url) 

        dim http 

        set http=Server.createobject("Microsoft.XMLHTTP") 

        Http.open "GET",url,false 

        Http.send() 

        if Http.readystate<>4 then

                exit function 

        end if 

        getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")

        set http=nothing

End function



Function PostHTTPPage(url,strForm)

        dim http 

        set http=Server.createobject("Microsoft.XMLHTTP") 

        Http.open "POST",url,false 

        http.setRequestHeader "Content-Length",len(strForm)

    http.setRequestHeader "Content-Type","application/x-www-form-urlencoded"

        Http.send(strForm)        

        if Http.readystate<>4 then

                exit function 

        end if 

        PostHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")

        set http=nothing

End function


Function BytesToBstr(body,Cset)

        dim objstream

        set objstream = Server.CreateObject("adodb.stream")

        objstream.Type = 1

        objstream.Mode =3

        objstream.Open

        objstream.Write body

        objstream.Position = 0

        objstream.Type = 2

        objstream.Charset = Cset

        BytesToBstr = objstream.ReadText 

        objstream.Close

        set objstream = nothing

End Function


url=Request.ServerVariables("HTTP_REFERER")


Html=getHTTPPage(url)

           Set re=new RegExp

        re.IgnoreCase =true

        re.Global=True

        re.Pattern="(<tr><td align=""center""><img src="")(.+?)("")"

        aa=re.Replace(Html,"{fuckbaidu}$2{fuckbaidu}")

imgurls=split(aa,"{fuckbaidu}")


i=ubound(imgurls)

if i=0 then 

response.end()

end if

randomize

s=Int(i*Rnd +1)

if  (s mod 2 =0) then

s=s-1

end if

while  imgurls(s)="头像地址"

s=Int(i*Rnd +1)

if  (s mod 2 =0) then

s=s-1

end if

wend


imgurl=imgurls(s)


Response.Buffer = True 

Response.ExpiresAbsolute = Now() - 1 

Response.Expires = 0 

Response.CacheControl = "no-cache" 


  Dim objXMLHTTP, xml

  Set xml = Server.CreateObject("Microsoft.XMLHTTP")  

  xml.Open "GET",imgurl,False

  xml.Send   

Response.BinaryWrite xml.responseBody

set xml=nothing

%>

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。