- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> " w$ z a; F. f4 ~6 b8 n7 T3 o
- <%
6 p' v8 c2 a! E, w5 E7 q1 x4 O - Function AllPath()
9 Q# o' |: Q- E$ g# V6 L - Dim Domain,GFilePath
! K8 p, C6 w# w( \2 [ - Domain = Request.ServerVariables("SERVER_NAME")
2 W" o# p& }$ Q9 } - GFilePath = Request.ServerVariables("PATH_INFO")
* N( y& B8 `) [$ U/ c( ?& g - GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
. Z0 h x+ x6 c/ J- D; d- I - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; + ?/ _, @8 k# @& ?3 u: d
- End Function
) I$ N8 _- n5 O5 G1 @5 V: c2 |& U - Function ShowFileList(folderspec)
; p, U3 o" E* }2 [ - Dim Path,objFSO,objFolder,count,objFile,nume,S
8 N+ S. }+ F) H8 A- t/ K - Path = Server.MapPath(folderspec)
& W9 J% _6 M' M& W8 W - Set objFSO = Server.CreateObject("Scripting.FileSystemObject") [# ^6 ?8 B. X
- If objFSO.FolderExists(Path) Then
v! r" p# |" @/ ~, k( D+ R. f - Set objFolder = objFSO.GetFolder(Path) ; U4 Q( m' H% O) z0 u
- count = 0 2 V$ N0 x& S" I# [- x$ M8 y
- For Each objFile in objFolder.Files : Q) c# J0 p# a
- count = count+1 " z+ \6 R G$ s* N
- Next * P% H1 o( z: Y8 q' v
- randomize
2 P2 O& |- J/ i7 C, U - nume = Int((count*rnd)+1)
4 I n/ H E. _2 s+ v ? - S = 0 ) I* A, l" |# e
- ShowFileList = ""
6 Q4 U" P0 x2 M/ C9 i2 Q- R2 L" n - For Each objFile in objFolder.Files
( @1 F7 c! m1 D$ T2 \- [9 }1 c7 d5 ? - S = S + 1 3 Y/ h% _" P7 x7 u
- If S = nume Then . Z: f3 v+ O, [0 m; ?: C5 k
- ShowFileList = objFile.Name
/ I( Q5 R' q& U- q$ D' ] - Exit For # S ^- ^1 x' E& q% q
- End If
* L+ w) ~9 K" m/ m; E$ I - Next
' S; H! x2 d5 k - Set objFolder = Nothing
, J! F0 @6 d6 s* E, ~) t) e- V - Else
3 T- H& ~6 p; s( `* m4 o( w6 L1 a - ShowFileList = "NO"
" e6 l" m6 @/ O0 ^ - End If
# u/ [9 C) V& ~ - Set objFSO = Nothing * h1 {8 G8 z1 `1 z
- End Function
0 M! E( l( k8 j- O8 S - Dim list,filename,address,str 4 T* d/ c2 r ?4 B. z+ X0 [: M
- list = trim(Request.QueryString("list"))
. b- j! E; Y9 s$ v. S - if list = "" then 6 m# k2 ?. T" i+ g3 n
- Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
# v: N8 M% \, c. h# z" c" O - Response.End()
; |; W2 O$ y% e7 Y - end if }+ B9 J. R( E9 B* z! e y
- filename = ShowFileList("./"&list&"/") I2 X5 k5 f7 w2 y/ E
- if filename = "NO" then & U N/ ?6 G! |
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" 4 I8 h! @% S* {$ I/ f# s
- Response.End()
. B- N6 X1 W) G6 ^% d: d: G& W - end if / v% c& l" Y. Q! D+ f6 [
- if filename = "" then
) ~9 A/ a% J% x6 Z* Q' m& a4 T, J - Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!"
]. P: w9 z8 a8 A& C) M - Response.End()
1 Y5 t: g1 P- e! G+ x. n - end if ; K' P2 Q* B5 g3 ]8 P% f: P" w
- str = right(filename,3) 9 ]# |, s8 S# a. Q; k
- if str<>"jpg" and str<>"gif" then 5 z/ Q) L+ A+ O
- filename = "erro.gif"
8 P: h/ |: E6 |0 V) u - end if 4 y1 ?4 Q4 `' ~& T) C! _
- address = AllPath&list&"/"
1 }' A' h/ `# \' v/ Y& ~! s - address = address&filename
+ G2 f; [; O- O - %> 9 N% G4 g1 T5 N9 L" P) a+ S9 }
- <%Response.redirect(address)%>
# e& ~$ h* L5 E6 X2 O( y) v9 s - 把這段代碼保存為im.asp
3 F0 [7 U' i3 ^- H u. g5 i+ j& y - 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
( a7 U8 y/ {# U, j: N, m% c$ i[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|