- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> 9 ]- q2 S+ f, g: \3 H2 \9 H
- <%
& y; O: S! Q# ^* @ - Function AllPath() * r7 b) B3 @; @/ U
- Dim Domain,GFilePath 7 P+ m' Y6 o0 g9 ]* ]
- Domain = Request.ServerVariables("SERVER_NAME") ! D6 P) F2 O5 M
- GFilePath = Request.ServerVariables("PATH_INFO")
( }- K1 v; l0 H - GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/"))) 5 Q. S1 k/ V) a2 r' p
- AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; 1 A4 H' V. N1 _1 L1 x1 o
- End Function 3 t( F" |$ V% ^( [8 @5 G
- Function ShowFileList(folderspec) 7 p; U+ M/ [; T0 B& D3 C' T6 X
- Dim Path,objFSO,objFolder,count,objFile,nume,S
. Q1 a) x' l U6 |1 v# m$ c - Path = Server.MapPath(folderspec) 3 Y% l6 ~$ N- q& G+ P; d, t
- Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 4 y* K4 M% j0 k
- If objFSO.FolderExists(Path) Then 0 |' ~; |% h4 S, V" T
- Set objFolder = objFSO.GetFolder(Path) % m, X- N5 i: }; u
- count = 0
: w; m, p" }( p" x4 J+ { - For Each objFile in objFolder.Files 3 m- o& d/ v0 T" _ u
- count = count+1
' U- F* Y$ }* P( a8 S0 \8 p7 z+ s( B - Next
7 G8 s0 x7 q* V- |3 O4 C5 J" } - randomize $ a/ k, \/ L% g* H+ _6 d( \, L
- nume = Int((count*rnd)+1) " o4 F c: T( n, J
- S = 0 9 w4 k. Y' h& `% N# f9 S2 [
- ShowFileList = ""
" F3 M5 U, s& W; ]; l2 S - For Each objFile in objFolder.Files 4 A4 {8 l5 I" L- F/ ~ f
- S = S + 1 # N2 L4 H& a6 @
- If S = nume Then 0 K$ m8 C. z% v( p
- ShowFileList = objFile.Name ) ^( N! \0 o, x+ r. F5 D w8 u- g
- Exit For : u. o$ {) b) ]( I1 d
- End If " y1 q$ L; u" E5 Q, S' j
- Next
1 s' d+ w! V2 W, ]0 C6 r9 M4 B5 f1 I - Set objFolder = Nothing
, N& H2 B2 H8 _8 O - Else . D: ~; [$ V% V) ^7 N! P7 J
- ShowFileList = "NO" : I( _) Z/ k6 J
- End If
& f2 h0 J# @4 Q k q2 X" t8 i: ^% L! B - Set objFSO = Nothing 0 W: t# Z _3 ]
- End Function # b3 B& V$ i7 _7 C* j q
- Dim list,filename,address,str ! ~5 s7 ^( q {& I2 o
- list = trim(Request.QueryString("list")) 7 L* Z/ t: D. t, k
- if list = "" then 6 U( E( f/ Q# b* t% n$ A
- Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
/ g8 r0 T2 r9 f- \- ] - Response.End() 8 |2 j8 A o0 J) o& n% h
- end if
4 b. G& a. \% J- [; a# A3 u+ Z) u0 n" h - filename = ShowFileList("./"&list&"/") 9 l. u9 v* m8 y/ N
- if filename = "NO" then - Z. {9 [' T4 \, T
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!"
& V; s* y& W5 M6 o& G! ?. E6 X - Response.End()
0 r( Q. G' k* I4 h# w D - end if % H# `4 H+ J. V. V/ ]
- if filename = "" then $ [$ w+ l5 V' i# N, u$ S$ J$ q
- Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" - `% W2 ]3 i9 T9 C1 \+ P
- Response.End()
& [# b2 R, u: W& V - end if
/ d! P3 e% i& k5 X7 H, [( C - str = right(filename,3)
. K8 F) |$ ~2 R: d5 s* x - if str<>"jpg" and str<>"gif" then
, J, c. ^$ w0 y" `4 d) T! ?' e/ l - filename = "erro.gif" . I- H. c) R: S8 b4 x
- end if 8 Z9 E [1 S p8 b" w& F! ~
- address = AllPath&list&"/"
) p$ f+ K' R+ g" V8 }4 h+ t3 P/ [& w - address = address&filename
: S0 M4 j; O( G# y) I( m/ z& `& o - %>
! ~5 \# j9 r1 I1 e - <%Response.redirect(address)%>
4 a b$ u6 }. L3 k9 } ^/ ? - 把這段代碼保存為im.asp
3 K# B: q1 F+ J8 L! O+ K7 c& o - 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
3 C5 p! p) |8 r4 }8 x[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|