- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> : h( A5 P; ]9 m% s, U! T( O
- <% 4 D, c9 y1 C% @ S! e# ?5 t) t0 E
- Function AllPath() ! r# h) o' }2 M' j) r
- Dim Domain,GFilePath 3 W1 I+ {: e) Q% D8 C3 q
- Domain = Request.ServerVariables("SERVER_NAME") 4 w5 f# ^& Z& i% O
- GFilePath = Request.ServerVariables("PATH_INFO") 0 a: Q9 y5 i- y, Z2 C6 A/ w
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/"))) I/ p6 ? B/ }4 U
- AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ;
. B! F/ y5 D. Q6 E' A: e: i* s5 T5 T0 m - End Function
# ~( d% h4 f& E: w* M - Function ShowFileList(folderspec) / N! t j8 z( h7 Q/ e
- Dim Path,objFSO,objFolder,count,objFile,nume,S 2 M. K; D/ e3 F9 N- y3 o
- Path = Server.MapPath(folderspec)
8 t9 U2 K; D2 z" ^& n. Z - Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
9 e' B: U& S& w; `/ f - If objFSO.FolderExists(Path) Then 9 F' U* N* z2 B) g/ f% v
- Set objFolder = objFSO.GetFolder(Path)
4 C$ g: n5 P' { - count = 0 & f. ~2 T8 ~; m& k: b9 ?
- For Each objFile in objFolder.Files & A( J* C/ q# p a& h) H. f
- count = count+1 ' ]' Z* s! t3 P
- Next
8 y, e7 X, }$ ?: W3 Q - randomize ; j. ?+ U& ^5 N7 W4 l+ l# P
- nume = Int((count*rnd)+1)
8 a6 j% z$ p6 s6 \2 M# e* L - S = 0 7 Y$ ~4 e9 @, l3 I) e$ E+ ^3 x
- ShowFileList = "" - E$ _+ v" ^3 f {2 \/ G: F
- For Each objFile in objFolder.Files ' j1 Z* M3 C: d3 e7 B5 [0 o+ i s
- S = S + 1 ' E+ I7 C4 }( r% P9 H! k5 g
- If S = nume Then " u' g7 t+ @' l: r3 a/ u
- ShowFileList = objFile.Name . B/ u# K: ]9 @/ `0 O
- Exit For
5 k% q T/ U4 ~3 Y' ?- k - End If . [4 A: M$ `3 \ Y% @1 H- ^
- Next 3 m, z z; c. s
- Set objFolder = Nothing ! e, {% d! }3 y6 y1 G/ E, R
- Else , A3 q. t1 x& z( V# o
- ShowFileList = "NO"
! B9 o7 `5 y, k- |6 b0 a3 T - End If 8 |2 u0 y8 _ ~; u$ }
- Set objFSO = Nothing
# I! F: [' j; s - End Function : F; Q2 [6 g+ f) a5 ?+ F) w
- Dim list,filename,address,str + `6 {% _& w: Z$ N
- list = trim(Request.QueryString("list"))
7 d- R+ O* L5 j% A4 r; J - if list = "" then
# {$ q& U+ D0 ]* n - Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
4 c( a8 S i, Q* L0 @+ S* Y - Response.End() ( ], x' h2 h+ {
- end if % D5 G4 {, `3 ^: B
- filename = ShowFileList("./"&list&"/")
/ S o/ d1 @% A) Q' j1 e( a4 j - if filename = "NO" then & e& t. I2 b4 _/ ^; x
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" ! \+ r# K, J( q5 A
- Response.End() # ^2 x4 w9 a3 N2 H- M8 a2 d
- end if ( g ?2 Z4 n% z2 e% T
- if filename = "" then & D2 R9 h' J2 e3 ~: {
- Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" 0 T, I* h8 X3 i& ~; W. U
- Response.End()
4 x& S( T, `9 g6 U. j8 a6 }# C - end if
7 w: f) Z; f% U# Z - str = right(filename,3)
( M6 \$ s9 @* A1 r+ v# t - if str<>"jpg" and str<>"gif" then ( ]/ V1 W2 r ~5 [6 H
- filename = "erro.gif" 7 f7 ~/ k+ @8 p1 N$ H+ ]6 X {! y
- end if
8 B0 W) _3 I5 K) Q+ {- x# V - address = AllPath&list&"/" 1 G* N0 a8 D, K
- address = address&filename 0 f- }4 P1 z2 h, l& e7 O
- %>
4 r) T9 D t6 Q7 L: ^" o - <%Response.redirect(address)%> 0 A, Z) ~7 }$ B! S5 U/ z
- 把這段代碼保存為im.asp% w+ b2 y3 k0 w& b+ q, o% y; V
- 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
) k7 N7 |' d% K" W; I$ g[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|