- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
9 U# j6 r& }) a8 ^ - <% 7 D- Y8 @$ X! F1 b) a% |1 M
- Function AllPath()
- l7 W: D- i8 I! P - Dim Domain,GFilePath
0 a& ]) w, f- ], J" j3 k - Domain = Request.ServerVariables("SERVER_NAME")
3 T) L/ O a* W! q/ y" P2 X - GFilePath = Request.ServerVariables("PATH_INFO") % J- x" }+ x' X. U% M
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
/ g7 d( M3 o' \( I1 O( @ - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ;
' I& n6 o. ~3 b' W! y) z5 P - End Function - `3 E7 D7 c, R1 L
- Function ShowFileList(folderspec) ! u2 M8 u% v4 e
- Dim Path,objFSO,objFolder,count,objFile,nume,S
I9 l! X( U. J# F6 @6 s0 q8 s - Path = Server.MapPath(folderspec)
+ q4 c- _8 k, f/ \( v; O - Set objFSO = Server.CreateObject("Scripting.FileSystemObject") : I1 f. S& j& u) V# k
- If objFSO.FolderExists(Path) Then ) A; {, u% P( f4 ^
- Set objFolder = objFSO.GetFolder(Path)
' @* v+ I, ?3 k! o/ i7 z& { - count = 0
" C2 d" K# B( o' i w( B8 _ - For Each objFile in objFolder.Files ; U% O. _" _5 S7 h% A+ e0 U$ ^1 \
- count = count+1 9 Q( z: |/ s0 ~# R! z
- Next 5 h2 \/ y' s& ?$ H2 x. @
- randomize # z, x# t, O% R& l! E) z& X. c
- nume = Int((count*rnd)+1)
- {" ~ z* P, K j# E - S = 0
! |9 G3 t! h; W4 i; U - ShowFileList = ""
, j @" W( f% A2 Z- J - For Each objFile in objFolder.Files * E) O( w3 d) }3 X J7 v6 U
- S = S + 1
9 a. q, K' n' _; U- ^ - If S = nume Then
" n% _, V2 U9 H+ W - ShowFileList = objFile.Name
2 u! E$ Q I+ u7 U* Y5 Q - Exit For z8 c4 U, K7 s4 h1 E5 B
- End If
6 U5 n2 t: ^/ o# p - Next
* T6 u+ ~7 n( w& G. r - Set objFolder = Nothing T, F( n( h2 S5 r5 T6 P3 [. F
- Else / b% a" y! ?4 @$ M
- ShowFileList = "NO" - _6 p/ E% y' H: {" A" S- x
- End If
1 @% U! H. i+ j) v6 i& a, A, m - Set objFSO = Nothing / R! E7 |2 t4 }. J
- End Function
* n3 X$ `9 {; @7 \ - Dim list,filename,address,str
4 p, {- {0 G9 k p& z' O - list = trim(Request.QueryString("list")) 4 s1 _0 h( z& T; J+ V# V
- if list = "" then $ P+ n2 x3 c9 E7 Z
- Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
; p0 V, [2 N& V; X5 ?; B! D. @/ P3 r - Response.End()
: w1 `( i/ w& P0 i7 k9 Z3 P - end if
+ d0 `6 h1 N( q+ @- p2 f5 } - filename = ShowFileList("./"&list&"/") ( F% T1 x" [8 O+ ]
- if filename = "NO" then . {1 j) M9 e7 J" d+ o b
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" $ W6 O( @% P+ H! t |6 f! ]
- Response.End()
6 z4 E; ~6 A4 d# q6 _8 O - end if
7 [7 l- G- M. U0 q7 S - if filename = "" then . M: Y* h. f; ?4 k# d' T$ [
- Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!"
! k4 i1 i1 p6 k6 p+ \ - Response.End() , s2 h+ t1 I7 e: s6 L/ D
- end if
6 D* ], Y" z0 u+ \, J# Y; r - str = right(filename,3)
2 M; K6 W' N# L" K+ U: ^ - if str<>"jpg" and str<>"gif" then 9 {8 V- t/ I9 ] ]7 U
- filename = "erro.gif" ( g, a& Z/ X/ V# ]5 l- b g) p
- end if 5 A! e( `8 w% j3 c4 m% x
- address = AllPath&list&"/" , o, B$ ]8 p; \3 }
- address = address&filename
1 a" V4 j* x/ n. c5 A0 W" c, z& R - %> : R$ t' n# J) f: c: f$ ~. F2 S3 @
- <%Response.redirect(address)%>
+ [8 Z4 d7 A/ l, a# H - 把這段代碼保存為im.asp
( B, L& f: x1 P- P: v, o" C0 x - 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼 ; T# X; ^/ M, |1 T; ]0 c
[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|