- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> 7 c: V; r2 z% P
- <% : f$ ^- r: ^6 q* {3 D8 @- \& H
- Function AllPath() - |% J8 q$ n' Q
- Dim Domain,GFilePath ; o$ }. d/ u3 t( o+ u
- Domain = Request.ServerVariables("SERVER_NAME")
: _, W$ w2 i) \8 y. g$ [+ R - GFilePath = Request.ServerVariables("PATH_INFO") ; g% U+ D, [2 t/ s, P: U R% a4 a7 D
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
$ W6 n- H3 [( O5 G5 [, w/ x - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; 3 T% O/ W) g2 p: r& K W# @4 [3 N3 J
- End Function
" ^% Y4 }. j t& D: D% F - Function ShowFileList(folderspec) 5 }5 h+ e+ [+ }* D9 ?
- Dim Path,objFSO,objFolder,count,objFile,nume,S
* T' U2 S- o( x: s6 f+ U- \* g - Path = Server.MapPath(folderspec)
1 u+ H3 T( l P2 n8 y3 n) g6 N - Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 3 C4 Y+ `' \3 t* i
- If objFSO.FolderExists(Path) Then
4 B( C4 q2 k2 X) f - Set objFolder = objFSO.GetFolder(Path) * w& ~' Q3 I3 D0 m7 a* U) m8 N
- count = 0 + c% L# p# A5 p7 X$ O& V
- For Each objFile in objFolder.Files + w& ^5 s" V( n# z# r0 m6 d+ d' x
- count = count+1
, _5 u2 Q( H! z - Next
; c0 L0 @, ~) M4 N& n - randomize
H+ i% X8 D* R/ s - nume = Int((count*rnd)+1) 5 w2 w4 L$ d' M1 Y7 n& [- A
- S = 0
, ?: O T: _% _1 @ - ShowFileList = "" : ]8 {" S+ I2 `9 S. X
- For Each objFile in objFolder.Files
* p1 x( y: r7 Z0 J: Z9 c# E* [ - S = S + 1 , q0 J. F8 l& I% K% C
- If S = nume Then ; N% y: p: Q4 f! C& D. k' Q
- ShowFileList = objFile.Name $ v% r3 g+ e' y5 o1 ^! z
- Exit For . G: k+ F0 j$ i; S/ I: ~% r
- End If
3 B- r8 ~" N1 N$ p - Next
, F! Q; O& `7 [) \' ]* u8 r - Set objFolder = Nothing + l6 v0 N( @! Y& s/ e1 V- y
- Else
3 V2 P' @1 [- u - ShowFileList = "NO"
& m) B. k! Y5 Z- Y8 ~ - End If
8 F! I; {, l6 D5 {- _- ? - Set objFSO = Nothing / F, u+ h$ L; J; [- g" b
- End Function
7 V& L7 ^+ F6 [ - Dim list,filename,address,str
' {& B) R4 D+ m4 J/ I+ j$ @ - list = trim(Request.QueryString("list"))
# S- j- u7 Y: P+ ^ ? - if list = "" then
7 b6 e' c. C* K6 c* ] - Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg" ; U( v C! g( v, c% Y0 Z! Q ?
- Response.End() * D1 c' c9 M# B# U: m# B8 m% n
- end if
. x* B1 b$ ~9 n' N0 k: { - filename = ShowFileList("./"&list&"/")
# F: [, B+ e6 {' ~: C" ]) ? - if filename = "NO" then * b" k* s; G' n+ S# H' N
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!"
% O4 ~* e- n8 ^( s- h3 T& j& F- s - Response.End()
2 u# J* Y' i) ^8 t, R. f - end if
9 S$ G) d& e9 s3 d# P+ |7 i( ^+ m' h - if filename = "" then " N/ T9 m& J( w. N ~& P+ f
- Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" 1 F) n( E( C8 f; { g3 p
- Response.End() $ r2 d* t; n* t8 _
- end if
1 s) t6 s. o2 B9 {4 ? - str = right(filename,3) 7 E% s! _* n I% W% H" d* ]% c1 o
- if str<>"jpg" and str<>"gif" then
$ \' P, p5 y% |6 F3 A+ L8 O6 e - filename = "erro.gif" 2 E4 s# O% B- b+ G) n W0 ~
- end if
$ {; h' r# P. E - address = AllPath&list&"/"
" m7 @3 d% a) Y- b' Z9 b - address = address&filename # }/ q" C& p# ~/ q. p+ T+ W
- %>
) V0 H+ u5 ^5 n, Z: |) }# ~% \ - <%Response.redirect(address)%> ( _; _% u5 M! \ H
- 把這段代碼保存為im.asp
5 Z' \2 t6 F( e1 v% S3 R - 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
$ T: n: t; O! o5 T. J8 r6 F' B[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|