- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> . y6 [' ~5 I7 z' V! ?
- <%
' m* c& }$ S9 x! w4 \' Y - Function AllPath() 3 f1 U! N6 A5 d
- Dim Domain,GFilePath
( X# A, Y4 U; T/ e - Domain = Request.ServerVariables("SERVER_NAME")
/ r9 s0 H) {/ D& X% N4 g - GFilePath = Request.ServerVariables("PATH_INFO")
+ x: M, U2 x2 D- }; n - GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/"))) 6 o0 \( G9 D3 E! q( p: x
- AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; ( J7 n* a9 f; l3 ^; `, D
- End Function
8 o6 T5 F; I I6 v# N: y$ ?, `9 O+ X; ^ - Function ShowFileList(folderspec)
3 f6 l% |7 e w5 D( ~ - Dim Path,objFSO,objFolder,count,objFile,nume,S
. c' I1 J7 \8 K6 f) Y$ Y U4 P( Y - Path = Server.MapPath(folderspec)
% C b% M: Y% h' e9 r2 U; l - Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
2 h6 D9 \ w/ ^( v' \" @" n - If objFSO.FolderExists(Path) Then z/ n/ C: s$ H! {) Y
- Set objFolder = objFSO.GetFolder(Path)
6 J6 N' G. a7 H - count = 0 : Q7 Z1 Z& G# C* e, x
- For Each objFile in objFolder.Files
1 c' D6 f1 N+ D; ]1 d+ A# S' \' }# z - count = count+1 _* L3 s" j E% K& A* l: o, q3 `
- Next ; L9 y5 q% M: _6 I9 q) U9 ^
- randomize 0 |" {+ v) B! b3 M6 U1 F; ?
- nume = Int((count*rnd)+1)
) p5 K/ ~" G+ g6 W - S = 0
2 s4 w7 Y# h1 { - ShowFileList = ""
5 c' t, P# j% w - For Each objFile in objFolder.Files % T1 |5 W4 i; o( b) l# L
- S = S + 1
: k5 i! z2 f. L8 M/ F9 S - If S = nume Then
2 N: p @5 {# w8 i% r - ShowFileList = objFile.Name
7 b8 Y- p5 A% A7 W, d - Exit For 3 \- e1 o5 U" ^0 Z, v
- End If 3 B5 V4 b# ^7 C
- Next 3 O6 u" L6 y# F/ }" n2 n; }
- Set objFolder = Nothing
6 Q* z. M) w# _3 {8 [% b+ w- | - Else 1 y% z( H5 t1 P l* r& U
- ShowFileList = "NO" + w( B; ?) o! F9 c3 T/ g! b; h
- End If % ]3 B. N# ~ m$ P# B
- Set objFSO = Nothing
" w1 K$ ]+ _0 U - End Function / E7 x: [& U0 C M5 X$ o% k8 U
- Dim list,filename,address,str " D1 ]" _; y1 g
- list = trim(Request.QueryString("list")) . P! V1 v* e m; ^% F. ~; |
- if list = "" then 3 }1 d3 H. F# t
- Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg" + X( U6 i; C# W+ i1 s" P+ B
- Response.End() / ?. l5 n2 @/ D) f- i
- end if
$ E: y8 D/ ?& d( H - filename = ShowFileList("./"&list&"/") : W5 W! p C4 S1 \
- if filename = "NO" then
3 |. P h! s. \# f0 \, u2 R" T% A9 ? - Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!"
$ V5 a; G/ Z8 F: ~+ @, @9 j% M - Response.End()
, |; V$ r7 L. s [( t, m2 b - end if
2 V* B/ }& v' O0 w0 P3 ]2 K - if filename = "" then
. e" e/ T$ c z0 b5 J: s - Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" + h6 j3 P2 }' P7 |/ C/ ]
- Response.End() * P& m# J7 B+ z2 ]( @) B
- end if 2 n" @3 i0 G, y( ?/ t/ `( X v* x
- str = right(filename,3)
+ h; ?& k1 M& N9 ^ - if str<>"jpg" and str<>"gif" then
% \$ Q' o* O; [ - filename = "erro.gif" ; @" b3 @0 {6 ^
- end if - |4 x6 N7 {1 g Y! c2 ]
- address = AllPath&list&"/" 1 M Z9 Y0 u8 ]+ N9 T1 @8 B
- address = address&filename
7 ?, w! N; l; V" ]) H' H - %>
# `% R1 X6 L! M' x5 t( ~ - <%Response.redirect(address)%> / E% ~- a8 v* N$ M' W3 h( n
- 把這段代碼保存為im.asp
5 Y2 Y- Z# t5 V% a$ \5 Z4 G - 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼 6 B) N, }! C4 m7 l
[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|